chore(common): extend getRequiredEnvVar method to check empty values #15
Workflow file for this run
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
| name: relayer-test | |
| # NOTE: could be parametrized with which package to test when we have a specific transaction manager different from the relayer itself. | |
| on: | |
| pull_request: | |
| permissions: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| jobs: | |
| check-changes: | |
| name: relayer-test/check-changes | |
| permissions: | |
| actions: 'read' # Required to read workflow run information | |
| contents: 'read' # Required to checkout repository code | |
| pull-requests: 'read' # Required to read pull request information | |
| runs-on: ubuntu-latest | |
| outputs: | |
| changes-rust-files: ${{ steps.filter.outputs.rust-files }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: 'false' | |
| - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
| id: filter | |
| with: | |
| filters: | | |
| rust-files: | |
| - .github/workflows/relayer-tests.yaml | |
| - relayer/** | |
| unit-test: | |
| name: relayer-test/unit-test (bpr) | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }} | |
| permissions: | |
| contents: 'read' # Required to checkout repository code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Project | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| token: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }} | |
| submodules: recursive | |
| - name: Setup Rust toolchain file | |
| run: cp relayer/rust-toolchain.toml . | |
| - name: Rust setup | |
| uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 | |
| - name: Cache Rust dependencies and build artifacts | |
| uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 | |
| with: | |
| workspaces: relayer | |
| key: rust-build-relayer | |
| cache-targets: true | |
| cache-all-crates: true | |
| - name: Format | |
| working-directory: relayer | |
| run: cargo fmt --all -- --check | |
| - name: Build for tests (no rpc mock) | |
| working-directory: relayer | |
| run: cargo test --no-run --lib | |
| - name: Unit tests | |
| working-directory: relayer | |
| run: RUST_BACKTRACE=full make test-unit | |
| clippy: | |
| name: relayer-test/clippy (bpr) | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }} | |
| permissions: | |
| contents: 'read' # Required to checkout repository code | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Project | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| token: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }} | |
| submodules: recursive | |
| - name: Setup Rust toolchain file | |
| run: cp relayer/rust-toolchain.toml . | |
| - name: Setup Rust | |
| uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 | |
| - name: Cache Rust dependencies | |
| uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 | |
| with: | |
| workspaces: relayer | |
| key: rust-build-relayer | |
| - name: Clippy | |
| working-directory: relayer | |
| run: cargo clippy -- -D warnings | |
| integration-test: | |
| name: relayer-test/integration-test (bpr) | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.changes-rust-files == 'true' }} | |
| permissions: | |
| contents: 'read' # Required to checkout repository code | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: cgr.dev/zama.ai/postgres:17.9@sha256:d42847b7c5f9ece73655164588b2387dcd5fadd618ea64761c19d3484498cef0 | |
| credentials: | |
| username: ${{ secrets.CGR_USERNAME }} | |
| password: ${{ secrets.CGR_PASSWORD }} | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: relayer_db | |
| ports: | |
| - 5432 | |
| options: >- | |
| --health-cmd "pg_isready -U postgres -d relayer_db" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| env: | |
| SQLX_OFFLINE: true # Use cached queries for compilation (speeds up CI) | |
| APP_GLOBAL__MOCK_TEST: true | |
| DB_USER: postgres | |
| DB_PASSWORD: postgres | |
| DB_NAME: relayer_db | |
| steps: | |
| - name: Checkout Project | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| token: ${{ secrets.BLOCKCHAIN_ACTIONS_TOKEN }} | |
| submodules: recursive | |
| - name: Set database URLs | |
| env: | |
| DB_PORT: ${{ job.services.postgres.ports['5432'] }} | |
| run: | | |
| { | |
| echo "DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}" | |
| echo "APP_STORAGE__SQL_DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}" | |
| echo "TEST_DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}" | |
| } >> "$GITHUB_ENV" | |
| - name: Setup Rust toolchain file | |
| run: cp relayer/rust-toolchain.toml . | |
| - name: Setup Rust | |
| uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1 | |
| - name: Cache Rust dependencies and build artifacts | |
| uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 | |
| with: | |
| workspaces: relayer | |
| key: rust-build-relayer | |
| cache-targets: true | |
| cache-all-crates: true | |
| - name: Install SQLx CLI | |
| run: | | |
| if ! command -v sqlx &> /dev/null; then | |
| echo "Installing sqlx-cli..." | |
| cargo install sqlx-cli --no-default-features --features postgres | |
| else | |
| echo "sqlx-cli found in cache." | |
| fi | |
| - name: Migrate Database | |
| working-directory: relayer/relayer-migrate | |
| run: sqlx migrate run | |
| - name: Run tests | |
| working-directory: relayer | |
| run: RUST_BACKTRACE=full make test-run |