From 8b8e4496b6bd09bdb7bca1d79d957da922719981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Ma=C5=82ek?= Date: Wed, 1 Feb 2023 09:48:54 +0100 Subject: [PATCH] ci: build artifacts in parallel and add arm64 to release --- .github/workflows/release-testing.yaml | 83 +++++++++++++--- .github/workflows/release.yaml | 132 +++++++++++++------------ 2 files changed, 140 insertions(+), 75 deletions(-) diff --git a/.github/workflows/release-testing.yaml b/.github/workflows/release-testing.yaml index e767dbf4..540b6187 100644 --- a/.github/workflows/release-testing.yaml +++ b/.github/workflows/release-testing.yaml @@ -13,18 +13,15 @@ jobs: # Release Testing Job # -------------------------------------------------------------------------- - tests: - environment: gcloud + unit-tests: runs-on: ubuntu-latest steps: - - uses: Kong/kong-license@master - id: license - with: - password: ${{ secrets.PULP_PASSWORD }} - # -------------------------------------------------------------------------- - # Repository Checkout - # -------------------------------------------------------------------------- + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.PAT_GITHUB }} - name: setup golang uses: actions/setup-go@v3 @@ -39,18 +36,36 @@ jobs: restore-keys: | ${{ runner.os }}-build-codegen- + - name: run unit tests + run: make test.unit + + integration-tests: + runs-on: ubuntu-latest + steps: + + - uses: Kong/kong-license@master + id: license + with: + password: ${{ secrets.PULP_PASSWORD }} + - name: checkout repository uses: actions/checkout@v3 with: fetch-depth: 0 token: ${{ secrets.PAT_GITHUB }} - # -------------------------------------------------------------------------- - # Run Tests - # -------------------------------------------------------------------------- + - name: setup golang + uses: actions/setup-go@v3 + with: + go-version: '^1.19' - - name: run unit tests - run: make test.unit + - name: cache go modules + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-build-codegen- - name: run integration tests run: make test.integration @@ -58,6 +73,39 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} KONG_LICENSE_DATA: ${{ steps.license.outputs.license }} + e2e-tests: + environment: gcloud + runs-on: ubuntu-latest + steps: + + - uses: Kong/kong-license@master + id: license + with: + password: ${{ secrets.PULP_PASSWORD }} + + # -------------------------------------------------------------------------- + # Repository Checkout + # -------------------------------------------------------------------------- + + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.PAT_GITHUB }} + + - name: setup golang + uses: actions/setup-go@v3 + with: + go-version: '^1.19' + + - name: cache go modules + uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-build-codegen- + - name: run e2e tests run: make test.e2e env: @@ -67,6 +115,13 @@ jobs: GOOGLE_LOCATION: ${{ secrets.GOOGLE_LOCATION }} KONG_LICENSE_DATA: ${{ steps.license.outputs.license }} + release-tagging: + runs-on: ubuntu-latest + needs: + - unit-tests + - integration-tests + - e2e-tests + steps: # -------------------------------------------------------------------------- # Release Tagging # -------------------------------------------------------------------------- diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5bc25178..b4bb3666 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,23 +3,36 @@ name: release on: push: tags: - - "v*" + - "v*" workflow_dispatch: {} jobs: - # -------------------------------------------------------------------------- - # Release Job - # -------------------------------------------------------------------------- - - release: + artifacts: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - os: linux + arch: amd64 + - os: linux + arch: arm64 + - os: darwin + arch: amd64 + - os: darwin + arch: arm64 steps: # -------------------------------------------------------------------------- # Repository Checkout # -------------------------------------------------------------------------- + - name: checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: setup golang uses: actions/setup-go@v3 with: @@ -33,75 +46,72 @@ jobs: restore-keys: | ${{ runner.os }}-build-codegen- - - name: checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # -------------------------------------------------------------------------- - # Github Release + # Build & Upload Artifacts # -------------------------------------------------------------------------- - - name: release - id: create_release - uses: actions/create-release@v1 + - name: build for ${{ matrix.os }} ${{ matrix.arch }} + run: make build GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} + - name: upload ${{ matrix.os }} ${{ matrix.arch }} artifact + uses: actions/upload-artifact@v3 with: - draft: false - prerelease: false - release_name: ${{ github.ref }} - tag_name: ${{ github.ref }} - body: | - See the [CHANGELOG.md](https://raw.githubusercontent.com/Kong/kubernetes-testing-framework/main/CHANGELOG.md) - env: - GITHUB_TOKEN: ${{ github.token }} + name: bin + path: build/ktf.${{ matrix.os }}.${{ matrix.arch }} + if-no-files-found: error # -------------------------------------------------------------------------- - # Build & Upload Artifacts + # Generate Checksums # -------------------------------------------------------------------------- - - name: build linux amd64 artifacts - run: make build GOOS=linux GOARCH=amd64 - - name: upload linux amd64 artifacts - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./build/ktf.linux.amd64 - asset_name: ktf.linux.amd64 - asset_content_type: application/octet-stream - - - name: build mac amd64 artifacts - run: make build GOOS=darwin GOARCH=amd64 - - name: upload mac amd64 artifacts - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ github.token }} + - name: generate checksum for ${{ matrix.os }} ${{ matrix.arch }} artifact + run: sha256sum ktf.${{ matrix.os }}.${{ matrix.arch }} >> CHECKSUMS.${{ matrix.os }}.${{ matrix.arch }} + working-directory: ./build/ + - name: upload checksum for ${{ matrix.os }} ${{ matrix.arch }} + uses: actions/upload-artifact@v3 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./build/ktf.darwin.amd64 - asset_name: ktf.darwin.amd64 - asset_content_type: application/octet-stream + name: CHECKSUMS + path: build/CHECKSUMS.${{ matrix.os }}.${{ matrix.arch }} + if-no-files-found: error + + # -------------------------------------------------------------------------- + # Release Job + # -------------------------------------------------------------------------- + + release: + runs-on: ubuntu-latest + needs: + - artifacts + steps: # -------------------------------------------------------------------------- - # Generate Checksums + # Github Release # -------------------------------------------------------------------------- - - name: generate checksums for linux amd64 artifacts - run: sha256sum ktf.linux.amd64 >> CHECKSUMS - working-directory: ./build/ + - name: download checksums artifact + uses: actions/download-artifact@v3 + with: + name: CHECKSUMS - - name: generate checksums for mac amd64 artifacts - run: sha256sum ktf.darwin.amd64 >> CHECKSUMS - working-directory: ./build/ + - name: concatenate all checksums + run: cat CHECKSUMS.* > CHECKSUMS - - name: upload checksums - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ github.token }} + - name: download binary artifacts + uses: actions/download-artifact@v3 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./build/CHECKSUMS - asset_name: CHECKSUMS - asset_content_type: text/plain + name: bin + - name: Release + uses: softprops/action-gh-release@v1 + id: create_release + with: + draft: true + prerelease: true + name: ${{ github.ref }} + tag_name: ${{ github.ref }} + files: | + CHECKSUMS + ktf.* + body: | + See the [CHANGELOG.md](https://raw.githubusercontent.com/Kong/kubernetes-testing-framework/main/CHANGELOG.md) + env: + GITHUB_TOKEN: ${{ github.token }}