test(integration): add make target to run AWS LocalStack #3408
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Build and test | |
| on: [push] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| GHCR_REGISTRY: ghcr.io | |
| CI_TAG: ci-${{ github.sha }} | |
| jobs: | |
| basic-checks: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Check conventional commit | |
| uses: cocogitto/cocogitto-action@c7a74f5406bab86da17da0f0e460a69f8219a68c # v3 | |
| id: conventional_commit_check | |
| with: | |
| check-latest-tag-only: true | |
| - name: Check license header | |
| run: make check-license | |
| - name: Lint Markdown docs | |
| uses: DavidAnson/markdownlint-cli2-action@ded1f9488f68a970bc66ea5619e13e9b52e601cd # v23 | |
| with: | |
| globs: | | |
| *.md | |
| docs/*.md | |
| build: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| id-token: write | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Setup variables | |
| run: echo ROLLUPS_NODE_VERSION=`make version` >> $GITHUB_ENV | |
| - name: Login to GHCR | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Depot CLI | |
| uses: depot/setup-action@15c09a5f77a0840ad4bce955686522a257853461 # v1 | |
| - name: Build rollups-node image (amd64) | |
| uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1 | |
| with: | |
| file: Dockerfile | |
| context: . | |
| platforms: linux/amd64 | |
| tags: ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:devel-amd64-${{ env.CI_TAG }} | |
| push: true | |
| project: ${{ vars.DEPOT_PROJECT }} | |
| token: ${{ secrets.DEPOT_TOKEN }} | |
| - name: Build rollups-node image (arm64) | |
| uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1 | |
| with: | |
| file: Dockerfile | |
| context: . | |
| platforms: linux/arm64 | |
| tags: ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:devel-arm64-${{ env.CI_TAG }} | |
| push: true | |
| project: ${{ vars.DEPOT_PROJECT }} | |
| token: ${{ secrets.DEPOT_TOKEN }} | |
| - name: Build tester image | |
| uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1 | |
| with: | |
| file: Dockerfile | |
| context: . | |
| target: tester | |
| platforms: linux/amd64 | |
| tags: ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:tester-${{ env.CI_TAG }} | |
| push: true | |
| project: ${{ vars.DEPOT_PROJECT }} | |
| token: ${{ secrets.DEPOT_TOKEN }} | |
| - name: Build devnet image | |
| uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1 | |
| with: | |
| file: test/devnet/Dockerfile | |
| context: . | |
| platforms: linux/amd64 | |
| tags: ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node-devnet:${{ env.CI_TAG }} | |
| push: true | |
| project: ${{ vars.DEPOT_PROJECT }} | |
| token: ${{ secrets.DEPOT_TOKEN }} | |
| - name: Build debian package (amd64) | |
| uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1 | |
| with: | |
| file: Dockerfile | |
| context: . | |
| target: debian-packager | |
| platforms: linux/amd64 | |
| tags: ${{ github.repository_owner }}/rollups-node:debian-packager-amd64 | |
| push: false | |
| load: true | |
| project: ${{ vars.DEPOT_PROJECT }} | |
| token: ${{ secrets.DEPOT_TOKEN }} | |
| - name: Export deb package artifact (amd64) | |
| run: make copy-debian-package BUILD_PLATFORM=linux/amd64 DEB_ARCH=amd64 DEB_PACKAGER_IMG=${{ github.repository_owner }}/rollups-node:debian-packager-amd64 | |
| - name: Build debian package (arm64) | |
| uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1 | |
| with: | |
| file: Dockerfile | |
| context: . | |
| target: debian-packager | |
| platforms: linux/arm64 | |
| tags: ${{ github.repository_owner }}/rollups-node:debian-packager-arm64 | |
| push: false | |
| load: true | |
| project: ${{ vars.DEPOT_PROJECT }} | |
| token: ${{ secrets.DEPOT_TOKEN }} | |
| - name: Export deb package artifact (arm64) | |
| run: make copy-debian-package BUILD_PLATFORM=linux/arm64 DEB_ARCH=arm64 DEB_PACKAGER_IMG=${{ github.repository_owner }}/rollups-node:debian-packager-arm64 | |
| - name: Upload deb artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artifacts | |
| path: | | |
| cartesi-rollups-node-v${{ env.ROLLUPS_NODE_VERSION }}_amd64.deb | |
| cartesi-rollups-node-v${{ env.ROLLUPS_NODE_VERSION }}_arm64.deb | |
| lint: | |
| # disabled for now | |
| if: false | |
| runs-on: ubuntu-24.04 | |
| needs: [build] | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v6 | |
| - name: Login to GHCR | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull and tag tester image | |
| run: | | |
| docker pull ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:tester-${{ env.CI_TAG }} | |
| docker tag ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:tester-${{ env.CI_TAG }} \ | |
| cartesi/rollups-node:tester | |
| - name: Run linting | |
| run: make lint-with-docker | |
| unit-test: | |
| runs-on: ubuntu-24.04 | |
| needs: [build] | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v6 | |
| - name: Login to GHCR | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull and tag CI images | |
| run: | | |
| docker pull ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:tester-${{ env.CI_TAG }} | |
| docker pull ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:devel-amd64-${{ env.CI_TAG }} | |
| docker pull ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node-devnet:${{ env.CI_TAG }} | |
| docker tag ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:tester-${{ env.CI_TAG }} \ | |
| cartesi/rollups-node:tester | |
| docker tag ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:devel-amd64-${{ env.CI_TAG }} \ | |
| cartesi/rollups-node:devel | |
| docker tag ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node-devnet:${{ env.CI_TAG }} \ | |
| cartesi/rollups-node-devnet:devel | |
| - name: Cache test machine images | |
| uses: actions/cache@v5 | |
| with: | |
| path: test/downloads | |
| key: test-deps-${{ hashFiles('test/dependencies.sha256') }} | |
| - name: Download test dependencies | |
| run: make download-test-dependencies | |
| - name: Run unit tests | |
| run: make unit-test-with-compose | |
| # Runs the shard coverage guard and derives the integration matrix from the | |
| # Makefile's shard × topology cells, so adding a shard or topology never | |
| # requires a workflow change and an unassigned test fails fast here. | |
| integration-test-setup: | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| cells: ${{ steps.matrix.outputs.cells }} | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v6 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Check shard coverage | |
| run: make integration-test-shard-check | |
| - name: List shard x topology cells | |
| id: matrix | |
| run: echo "cells=$(make -s list-integration-cells)" >> "$GITHUB_OUTPUT" | |
| integration-test: | |
| runs-on: ubuntu-24.04 | |
| needs: [build, integration-test-setup] | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJson(needs.integration-test-setup.outputs.cells) }} | |
| env: | |
| COMPOSE_PROJECT: rollups-it-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.shard }}-${{ matrix.topology }} | |
| permissions: | |
| contents: read | |
| packages: read | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v6 | |
| - name: Login to GHCR | |
| uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4 | |
| with: | |
| registry: ${{ env.GHCR_REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull and tag CI images | |
| run: | | |
| docker pull ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:tester-${{ env.CI_TAG }} | |
| docker pull ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:devel-amd64-${{ env.CI_TAG }} | |
| docker pull ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node-devnet:${{ env.CI_TAG }} | |
| docker tag ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:tester-${{ env.CI_TAG }} \ | |
| cartesi/rollups-node:tester | |
| docker tag ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node:devel-amd64-${{ env.CI_TAG }} \ | |
| cartesi/rollups-node:devel | |
| docker tag ${{ env.GHCR_REGISTRY }}/${{ github.repository_owner }}/rollups-node-devnet:${{ env.CI_TAG }} \ | |
| cartesi/rollups-node-devnet:devel | |
| - name: Cache test machine images | |
| uses: actions/cache@v5 | |
| with: | |
| path: test/downloads | |
| key: test-deps-${{ hashFiles('test/dependencies.sha256') }} | |
| - name: Download test dependencies | |
| run: make download-test-dependencies | |
| - name: Run integration shard ${{ matrix.shard }} (${{ matrix.topology }}) | |
| run: | | |
| make integration-test-with-compose SHARD=${{ matrix.shard }} \ | |
| NODE_TOPOLOGY=${{ matrix.topology }} \ | |
| COMPOSE_PROJECT="$COMPOSE_PROJECT" | |
| - name: Upload integration test logs | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: integration-test-logs-${{ matrix.shard }}-${{ matrix.topology }} | |
| path: integration-logs-${{ matrix.shard }}-${{ matrix.topology }}.txt | |
| retention-days: 3 | |
| # Redundant with the trap in compose-integration-run.sh; this is the | |
| # safety net for when concurrency cancel-in-progress SIGKILLs the make | |
| # process before its trap can fire, which would otherwise leak the | |
| # project's containers and volumes. | |
| - name: Clean up compose project | |
| if: always() | |
| run: | | |
| docker rm -f "$COMPOSE_PROJECT-integration-test-run" >/dev/null 2>&1 || true | |
| ids="$(docker ps -aq \ | |
| --filter "label=com.docker.compose.project=$COMPOSE_PROJECT" \ | |
| --filter "label=com.docker.compose.service=integration-test" \ | |
| 2>/dev/null || true)" | |
| if [ -n "$ids" ]; then | |
| docker rm -f $ids >/dev/null 2>&1 || true | |
| fi | |
| docker compose -p "$COMPOSE_PROJECT" \ | |
| -f test/compose/compose.integration.yaml down -v --remove-orphans || true | |
| publish_artifacts: | |
| name: Publish artifacts | |
| needs: [basic-checks, build, unit-test, integration-test] | |
| runs-on: ubuntu-24.04 | |
| if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout emulator source code | |
| uses: actions/checkout@v6 | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v8 | |
| - name: Upload products to GitHub Release | |
| uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3 | |
| with: | |
| draft: true | |
| files: | | |
| artifacts/cartesi-rollups-node-v*.deb |