From e95c7f61805890a5030e14f5a4cbf85dff5e0051 Mon Sep 17 00:00:00 2001 From: arnaudberger Date: Thu, 5 Sep 2024 17:46:10 -0400 Subject: [PATCH] add workflow --- .github/workflows/main.yaml | 53 ++++++++++++++++++++++++++++++++ tests/evm-minimal/generator.json | 4 +-- tests/integration_test.go | 4 ++- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..3ad60d7 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,53 @@ +name: Build and Test + +on: + push: + branches: + - develop + - "codegen-cmd" + pull_request: + branches: + - "**" + +jobs: + test: + name: Test + runs-on: ${{ matrix.os }} + if: "${{ !startsWith(github.event.head_commit.message, 'GitBook: [#') }}" + strategy: + matrix: + go-version: [ 1.21.x ] + os: [ubuntu-latest, macos-latest] + env: + TEST_LOCAL_CODEGEN: "true", + RUN_INTEGRATION_TESTS: "true", + CODEGEN_MAINNET_API_KEY: ${{ secrets.CODEGEN_MAINNET_API_KEY }}, + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Check out code + uses: actions/checkout@v3 + + - name: Cache Go modules + uses: actions/cache@v3 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Run Tests + run: go test ./... + + - name: Build + run: go build ./... \ No newline at end of file diff --git a/tests/evm-minimal/generator.json b/tests/evm-minimal/generator.json index b58e32e..2b6acec 100644 --- a/tests/evm-minimal/generator.json +++ b/tests/evm-minimal/generator.json @@ -1,8 +1,8 @@ - +{ "generator": "evm-minimal", "state": { "name": "my_project", "chainName": "mainnet", "initialBlockSet": true } -} +} \ No newline at end of file diff --git a/tests/integration_test.go b/tests/integration_test.go index ae26429..4c5870f 100644 --- a/tests/integration_test.go +++ b/tests/integration_test.go @@ -28,11 +28,13 @@ func TestIntegration(t *testing.T) { name string stateFile string explorerApiKeyEnvName string + apiKeyNeeded bool }{ { name: "evm-events-calls", stateFile: "./evm-events-calls/generator.json", explorerApiKeyEnvName: "CODEGEN_MAINNET_API_KEY", + apiKeyNeeded: true, }, { name: "evm-minimal", @@ -103,7 +105,7 @@ func TestIntegration(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { explorerApiKey := os.Getenv(c.explorerApiKeyEnvName) - if explorerApiKey == "" { + if explorerApiKey == "" && c.apiKeyNeeded { fmt.Printf("NO %s has been provided, please make sure to provide it to enable code generation...", c.explorerApiKeyEnvName) }