|
2 | 2 |
|
3 | 3 | Here we describe our good practices for structuring different types of tests in Continuous Integration (GitHub Actions). |
4 | 4 |
|
5 | | -Follow [this](https://github.com/smartcontractkit/.github/tree/main/.github/workflows) guide. |
| 5 | +Set up secrets in your GitHub repository |
| 6 | +``` |
| 7 | +gh secret set CTF_SIMULATED_KEY_1 --body "..." |
| 8 | +``` |
| 9 | + |
| 10 | +Add a workflow |
| 11 | +```yaml |
| 12 | +name: Framework Golden Tests Examples |
| 13 | +on: |
| 14 | + push: |
| 15 | + |
| 16 | +jobs: |
| 17 | + test: |
| 18 | + defaults: |
| 19 | + run: |
| 20 | + working-directory: framework/examples/myproject |
| 21 | + env: |
| 22 | + LOKI_TENANT_ID: promtail |
| 23 | + LOKI_URL: http://localhost:3030/loki/api/v1/push |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + id-token: write |
| 27 | + contents: read |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + test: |
| 32 | + - name: TestSmoke |
| 33 | + config: smoke.toml |
| 34 | + count: 1 |
| 35 | + timeout: 10m |
| 36 | + - name: TestLoad |
| 37 | + config: load.toml |
| 38 | + count: 1 |
| 39 | + timeout: 10m |
| 40 | + - name: TestChaos |
| 41 | + config: chaos.toml |
| 42 | + count: 1 |
| 43 | + timeout: 10m |
| 44 | + steps: |
| 45 | + - name: Checkout repo |
| 46 | + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 |
| 47 | + - name: Configure AWS credentials using OIDC |
| 48 | + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 |
| 49 | + with: |
| 50 | + role-to-assume: ${{ secrets.PUBLIC_AWS_ECR_ROLE }} |
| 51 | + aws-region: us-east-1 |
| 52 | + - name: Authenticate to ECR Public |
| 53 | + id: login-ecr-public |
| 54 | + uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1 |
| 55 | + with: |
| 56 | + registry-type: public |
| 57 | + - name: Check for changes in Framework |
| 58 | + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 59 | + id: changes |
| 60 | + with: |
| 61 | + filters: | |
| 62 | + src: |
| 63 | + - 'framework/**' |
| 64 | + - name: Set up Go |
| 65 | + uses: actions/setup-go@v4 |
| 66 | + with: |
| 67 | + go-version: 1.22.8 |
| 68 | + - name: Cache Go modules |
| 69 | + uses: actions/cache@v3 |
| 70 | + with: |
| 71 | + path: | |
| 72 | + ~/.cache/go-build |
| 73 | + ~/go/pkg/mod |
| 74 | + key: go-modules-${{ hashFiles('framework/examples/myproject/go.sum') }}-${{ runner.os }}-framework-golden-examples |
| 75 | + restore-keys: | |
| 76 | + go-modules-${{ runner.os }}-framework-golden-examples |
| 77 | + go-modules-${{ runner.os }} |
| 78 | + - name: Install dependencies |
| 79 | + run: go mod download |
| 80 | + - name: Run Docker Component Tests |
| 81 | + if: steps.changes.outputs.src == 'true' |
| 82 | + env: |
| 83 | + CTF_CONFIGS: ${{ matrix.test.config }} |
| 84 | + run: | |
| 85 | + go test -timeout ${{ matrix.test.timeout }} -v -count ${{ matrix.test.count }} -run ${{ matrix.test.name }} |
| 86 | +``` |
| 87 | +
|
| 88 | +If you need to structure a lot of different end-to-end tests follow [this](https://github.com/smartcontractkit/.github/tree/main/.github/workflows) guide. |
0 commit comments