From c28c83e5cb21f8240a92e33e3543ac46bc6719e5 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Tue, 22 Oct 2024 08:20:20 -0500 Subject: [PATCH] test: parallelize e2e builds in gh action --- .github/workflows/e2e-test2.yml | 110 ++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 .github/workflows/e2e-test2.yml diff --git a/.github/workflows/e2e-test2.yml b/.github/workflows/e2e-test2.yml new file mode 100644 index 00000000000..4264e67d6d4 --- /dev/null +++ b/.github/workflows/e2e-test2.yml @@ -0,0 +1,110 @@ +name: "E2e test" + +on: + pull_request: + branches: [main] + +jobs: + build: + name: parallel buck2 builds + runs-on: ubuntu-latest + timeout-minutes: 25 + strategy: + matrix: + target: + - //core/api + - //core/api-ws-server + - //core/api-trigger + - //core/api-exporter + - //apps/dashboard + - //apps/consent + - //apps/pay + - //apps/admin-panel + - //apps/map + - //apps/voucher + - //core/api-keys + - //core/notifications + - //bats/helpers/callback:run + - //bats/helpers/subscriber:run + - //bats/helpers/totp:generate + fail-fast: false + + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v14 + + - name: Run the Magic Nix Cache + uses: DeterminateSystems/magic-nix-cache-action@v8 + + - name: Setup Buck cache + uses: actions/cache@v3 + with: + path: | + ~/.buck2 + buck-out + .buck-cache + prebuilt + installed + target + .buckd + buck-out/cache + key: buck2-${{ matrix.target }}-${{ hashFiles('**/BUCK', '**/BUCK.bzl', '**/MODULE.bazel', '**/deps.bzl') }} + + - name: Build ${{ matrix.target }} + run: | + nix develop -c buck2 kill + nix develop -c buck2 build ${{ matrix.target }} + + - name: Generate artifact name + id: artifact-name + run: | + SAFE_NAME=$(echo "${{ matrix.target }}" | sed 's|^//||' | sed 's|/|-|g' | sed 's|:run$||' | sed 's|:|-|g' | tr '[:upper:]' '[:lower:]') + echo "name=build-artifacts-${SAFE_NAME}" >> $GITHUB_OUTPUT + + - uses: actions/upload-artifact@v4 + with: + name: ${{ steps.artifact-name.outputs.name }} + path: | + buck-out + .buck-cache + prebuilt + installed + target + + tests: + needs: build + name: execute via bats + runs-on: ubuntu-latest + timeout-minutes: 25 + steps: + - uses: actions/checkout@v4 + + - name: Install Nix + uses: DeterminateSystems/nix-installer-action@v14 + + - name: Run the Magic Nix Cache + uses: DeterminateSystems/magic-nix-cache-action@v8 + + - name: Download all build artifacts + uses: actions/download-artifact@v4 + with: + pattern: build-artifacts-* + merge-multiple: true + + - name: Run bats tests + run: | + nix develop -c buck2 kill + nix develop -c bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/** + + - name: Rename Tilt log + if: always() + run: mv bats/.e2e-tilt.log bats/e2e-tilt.log + + - name: Upload Tilt log + if: always() + uses: actions/upload-artifact@v4 + with: + name: Tilt log + path: bats/e2e-tilt.log