From c6863f6eadeb82790e373561b63a3d5ff1227682 Mon Sep 17 00:00:00 2001 From: Jean du Plessis Date: Fri, 1 Nov 2024 16:44:36 +0200 Subject: [PATCH] Customize the CI workflow Signed-off-by: Jean du Plessis --- .github/workflows/ci.yml | 218 ++++++++++++++---- .github/workflows/native-provider-bump.yml | 17 -- .../{e2e.yaml => uptest-trigger.yaml} | 0 3 files changed, 175 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/native-provider-bump.yml rename .github/workflows/{e2e.yaml => uptest-trigger.yaml} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ac957b9ed..7700f00ff2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,19 +12,12 @@ on: pull_request: {} workflow_dispatch: {} -jobs: - ci: - uses: upbound/official-providers-ci/.github/workflows/provider-ci.yml@standard-runners - with: - go-version: "1.22" - golangci-skip: true # we will run the linter via "make lint" - cleanup-disk: true - secrets: - UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }} - UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_PSW }} +env: + GO_VERSION: "1.22" +jobs: detect-noop: - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest outputs: noop: ${{ steps.noop.outputs.should_skip }} steps: @@ -32,68 +25,72 @@ jobs: id: noop uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1 with: - github_token: ${{ secrets.GITHUB_TOKEN }} paths_ignore: '["**.md", "**.png", "**.jpg"]' do_not_skip: '["workflow_dispatch", "schedule", "push"]' - lint: - runs-on: ubuntu-24.04 + report-breaking-changes: + runs-on: ubuntu-latest needs: detect-noop if: needs.detect-noop.outputs.noop != 'true' + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: true + + - name: Get modified CRDs + id: modified-crds + uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c # v45.0.3 + with: + files: "package/crds/**" + + - name: Report breaking CRD OpenAPI v3 schema changes + if: steps.modified-crds.outputs.any_changed == 'true' + env: + MODIFIED_CRD_LIST: ${{ steps.modified-crds.outputs.all_changed_files }} + run: | + make crddiff + + - name: Report native schema version changes + run: | + make schema-version-diff + lint: + runs-on: ubuntu-latest + needs: detect-noop + if: needs.detect-noop.outputs.noop != 'true' steps: - name: Cleanup Disk uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 with: - android: true - dotnet: true - haskell: true - tool-cache: true large-packages: false swap-storage: false - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: submodules: true - name: Setup Go - uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5 + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 with: - go-version: "1.22" + go-version: ${{ env.GO_VERSION }} - - name: Find the Go Build Cache - id: go_cache + - name: Find the Analysis Cache + id: analysis_cache run: | - echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT && \ - echo "mod_cache=$(make go.mod.cachedir)" >> $GITHUB_OUTPUT && \ echo "analysis_cache=$HOME/.cache/golangci-lint" >> $GITHUB_OUTPUT && \ echo "analysis_cache_key=$(make go.lint.analysiskey)" >> $GITHUB_OUTPUT && \ echo "analysis_cache_key_int=$(make go.lint.analysiskey-interval)" >> $GITHUB_OUTPUT - - - - name: Cache the Go Build Cache - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 - with: - path: ${{ steps.go_cache.outputs.cache }} - key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-build-lint- - - - name: Cache Go Dependencies - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 - with: - path: ${{ steps.go_cache.outputs.mod_cache }} - key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-pkg- - name: Cache Linter Analysis uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4 id: cache-analysis with: - path: ${{ steps.go_cache.outputs.analysis_cache }} - key: ${{ steps.go_cache.outputs.analysis_cache_key }} + path: ${{ steps.analysis_cache.outputs.analysis_cache }} + key: ${{ steps.analysis_cache.outputs.analysis_cache_key }} restore-keys: | - ${{ steps.go_cache.outputs.analysis_cache_key_int }} + ${{ steps.analysis_cache.outputs.analysis_cache_key_int }} - name: Vendor Dependencies run: make vendor vendor.check @@ -105,3 +102,138 @@ jobs: RUN_BUILDTAGGER: true GOGC: "50" run: make lint + + check-diff: + runs-on: ubuntu-latest + needs: detect-noop + if: needs.detect-noop.outputs.noop != 'true' + steps: + - name: Cleanup Disk + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + with: + large-packages: false + swap-storage: false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: true + + - name: Setup Go + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Install goimports + run: go install golang.org/x/tools/cmd/goimports + + - name: Vendor Dependencies + run: make vendor vendor.check + + - name: Check Diff + id: check-diff + run: | + mkdir _output + make check-diff + env: + # check-diff depends on the generate Make target, and we would like + # to save a skipped resource list + SKIPPED_RESOURCES_CSV: ../_output/skipped_resources.csv + + - name: Show diff + if: failure() && steps.check-diff.outcome == 'failure' + run: git diff + + - name: Report Statistics + run: head -1 _output/skipped_resources.csv + + - name: Publish skipped resources CSV to Github + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: skipped_resources + path: _output/skipped_resources.csv + + unit-tests: + runs-on: ubuntu-latest + needs: detect-noop + if: needs.detect-noop.outputs.noop != 'true' + steps: + - name: Cleanup Disk + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + with: + large-packages: false + swap-storage: false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: true + + - name: Fetch History + run: git fetch --prune --unshallow + + - name: Setup Go + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Vendor Dependencies + run: make vendor vendor.check + + - name: Run Unit Tests + run: make -j2 test + + - name: Publish Unit Test Coverage + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 + with: + flags: unittests + file: _output/tests/linux_amd64/coverage.txt + + local-deploy: + runs-on: ubuntu-latest + needs: detect-noop + if: needs.detect-noop.outputs.noop != 'true' + steps: + - name: Cleanup Disk + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + with: + large-packages: false + swap-storage: false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: true + + - name: Fetch History + run: git fetch --prune --unshallow + + - name: Setup Go + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Vendor Dependencies + run: make vendor vendor.check + + - name: Deploying locally built provider package + run: make local-deploy + + check-examples: + runs-on: ubuntu-latest + needs: detect-noop + if: ${{ needs.detect-noop.outputs.noop != 'true' }} + + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + submodules: true + + - name: Check Example Manifests + run: | + ./scripts/check-examples.py package/crds examples + + + + diff --git a/.github/workflows/native-provider-bump.yml b/.github/workflows/native-provider-bump.yml deleted file mode 100644 index f01bf0b442..0000000000 --- a/.github/workflows/native-provider-bump.yml +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-FileCopyrightText: 2024 The Crossplane Authors -# -# SPDX-License-Identifier: CC0-1.0 - -name: Native Provider Version Bump - -on: - workflow_dispatch: {} - -jobs: - open-bump-pr: - uses: upbound/official-providers-ci/.github/workflows/native-provider-bump.yml@standard-runners - with: - provider-source: hashicorp/aws - go-version: 1.22 - secrets: - TOKEN: ${{ secrets.OFFICIAL_PROVIDERS_GA_TOKEN }} diff --git a/.github/workflows/e2e.yaml b/.github/workflows/uptest-trigger.yaml similarity index 100% rename from .github/workflows/e2e.yaml rename to .github/workflows/uptest-trigger.yaml