github.com/onflow/flow-go@v0.33.17/.github/workflows/ci.yml (about)

     1  name: CI
     2  
     3  on:
     4    push:
     5      branches:
     6        - 'auto-cadence-upgrade/**'
     7        - staging
     8        - trying
     9        - 'feature/**'
    10        - 'v[0-9]+.[0-9]+'
    11    pull_request:
    12      branches:
    13        - master*
    14        - 'auto-cadence-upgrade/**'
    15        - 'feature/**'
    16        - 'v[0-9]+.[0-9]+'
    17    merge_group:
    18      branches:
    19        - master
    20  
    21  env:
    22    GO_VERSION: "1.20"
    23  
    24  concurrency:
    25    group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
    26    cancel-in-progress: true
    27  
    28  jobs:
    29    golangci:
    30      strategy:
    31        fail-fast: false
    32        matrix:
    33          dir: [./, ./integration/, ./insecure/]
    34      name: Lint
    35      runs-on: ubuntu-latest
    36      steps:
    37      - name: Checkout repo
    38        uses: actions/checkout@v3
    39      - name: Setup Go
    40        uses: actions/setup-go@v4
    41        timeout-minutes: 10 # fail fast. sometimes this step takes an extremely long time
    42        with:
    43          go-version: ${{ env.GO_VERSION }}
    44          cache: true
    45      - name: Run go generate
    46        run: go generate
    47        working-directory: ${{ matrix.dir }}
    48      - name: Run golangci-lint
    49        uses: golangci/golangci-lint-action@v3
    50        with:
    51          # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
    52          version: v1.54
    53          args: -v
    54          working-directory: ${{ matrix.dir }}
    55          # https://github.com/golangci/golangci-lint-action/issues/244
    56          skip-cache: true
    57      
    58  
    59    tidy:
    60      name: Tidy
    61      runs-on: ubuntu-latest
    62      steps:
    63        - name: Checkout repo
    64          uses: actions/checkout@v3
    65        - name: Setup Go
    66          uses: actions/setup-go@v4
    67          timeout-minutes: 10 # fail fast. sometimes this step takes an extremely long time
    68          with:
    69            go-version: ${{ env.GO_VERSION }}
    70            cache: true
    71        - name: Run tidy
    72          run: make tidy
    73        - name: code sanity check
    74          run: make code-sanity-check
    75  
    76    create-dynamic-test-matrix:
    77      name: Create Dynamic Test Matrix
    78      runs-on: ubuntu-latest
    79      outputs:
    80        dynamic-matrix: ${{ steps.set-test-matrix.outputs.dynamicMatrix }}
    81      steps:
    82        - name: Checkout repo
    83          uses: actions/checkout@v3
    84        - name: Setup Go
    85          uses: actions/setup-go@v4
    86          timeout-minutes: 10 # fail fast. sometimes this step takes an extremely long time
    87          with:
    88            go-version: ${{ env.GO_VERSION }}
    89            cache: true
    90        - name: Set Test Matrix
    91          id: set-test-matrix
    92          run: go run utils/test_matrix/test_matrix.go admin cmd consensus engine/access engine/collection engine/common engine/consensus engine/execution/ingestion:buildjet-8vcpu-ubuntu-2204 engine/execution/computation engine/execution engine/verification engine:buildjet-4vcpu-ubuntu-2204 fvm ledger module/dkg module:buildjet-4vcpu-ubuntu-2204 network/alsp network/test/cohort1:buildjet-16vcpu-ubuntu-2204 network/test/cohort2:buildjet-4vcpu-ubuntu-2204 network/p2p/connection network/p2p/node:buildjet-4vcpu-ubuntu-2204 network/p2p/scoring network/p2p network state storage utils
    93  
    94    unit-test:
    95      name: Unit Tests (${{ matrix.targets.name }})
    96      needs: create-dynamic-test-matrix
    97      strategy:
    98        fail-fast: false
    99        matrix:
   100          targets: ${{ fromJSON(needs.create-dynamic-test-matrix.outputs.dynamic-matrix)}}
   101      ## need to set image explicitly due to GitHub logging issue as described in https://github.com/onflow/flow-go/pull/3087#issuecomment-1234383202
   102      runs-on: ${{ matrix.targets.runner }}
   103      steps:
   104      - name: Checkout repo
   105        uses: actions/checkout@v3
   106      - name: Setup Go
   107        uses: actions/setup-go@v4
   108        timeout-minutes: 10 # fail fast. sometimes this step takes an extremely long time
   109        with:
   110          go-version: ${{ env.GO_VERSION }}
   111          cache: true
   112      - name: Setup tests (${{ matrix.targets.name }})
   113        run: VERBOSE=1 make -e GO_TEST_PACKAGES="${{ matrix.targets.packages }}" install-tools
   114      - name: Run tests (${{ matrix.targets.name }})
   115        uses: nick-fields/retry@v2
   116        with:
   117          timeout_minutes: 35
   118          max_attempts: 5
   119          command: VERBOSE=1 make -e GO_TEST_PACKAGES="${{ matrix.targets.packages }}" test
   120        # TODO(rbtz): re-enable when we fix exisiting races.
   121        #env:
   122        #  RACE_DETECTOR: 1
   123      - name: Upload coverage report
   124        uses: codecov/codecov-action@v3
   125        with:
   126          file: ./coverage.txt
   127          flags: unittests
   128          name: codecov-umbrella
   129  
   130    unit-test-modules:
   131      name: Unit Tests (Modules)
   132      strategy:
   133        fail-fast: false
   134        matrix:
   135          include:
   136            - name: insecure
   137              setup: install-tools
   138              retries: 5
   139              race: 0
   140              runner: buildjet-4vcpu-ubuntu-2204
   141            - name: integration
   142              setup: install-tools
   143              retries: 5
   144              race: 0
   145              runner: buildjet-4vcpu-ubuntu-2204
   146      runs-on: ${{ matrix.runner }}
   147      steps:
   148        - name: Checkout repo
   149          uses: actions/checkout@v3
   150        - name: Setup Go
   151          uses: actions/setup-go@v4
   152          timeout-minutes: 10 # fail fast. sometimes this step takes an extremely long time
   153          with:
   154            go-version: ${{ env.GO_VERSION }}
   155            cache: true
   156        - name: Setup tests (${{ matrix.name }})
   157          run: make ${{ matrix.setup }}
   158        - name: Run tests (${{ matrix.name }})
   159          env:
   160            RACE_DETECTOR: ${{ matrix.race }}
   161          uses: nick-fields/retry@v2
   162          with:
   163            timeout_minutes: 35
   164            max_attempts: ${{ matrix.retries }}
   165            # run test target inside each module's root
   166            command: VERBOSE=1 make -C ${{ matrix.name }} test
   167        - name: Upload coverage report
   168          uses: codecov/codecov-action@v3
   169          with:
   170            file: ./coverage.txt
   171            flags: unittests
   172            name: codecov-umbrella
   173  
   174    docker-build:
   175      name: Docker Build
   176      runs-on: buildjet-16vcpu-ubuntu-2204
   177      steps:
   178        - name: Checkout repo
   179          uses: actions/checkout@v3
   180          with:
   181            # all tags are needed for integration tests
   182            fetch-depth: 0
   183        - name: Setup Go
   184          uses: actions/setup-go@v4
   185          timeout-minutes: 10 # fail fast. sometimes this step takes an extremely long time
   186          with:
   187            go-version: ${{ env.GO_VERSION }}
   188            cache: true
   189        - name: Docker build
   190          env:
   191            CADENCE_DEPLOY_KEY: ${{ secrets.CADENCE_DEPLOY_KEY }}
   192          run: make docker-native-build-flow docker-native-build-flow-corrupt
   193        - name: Save Docker images
   194          run: |
   195            docker save \
   196            gcr.io/flow-container-registry/access:latest \
   197            gcr.io/flow-container-registry/collection:latest \
   198            gcr.io/flow-container-registry/consensus:latest \
   199            gcr.io/flow-container-registry/execution:latest \
   200            gcr.io/flow-container-registry/ghost:latest \
   201            gcr.io/flow-container-registry/observer:latest \
   202            gcr.io/flow-container-registry/verification:latest \
   203            gcr.io/flow-container-registry/access-corrupted:latest \
   204            gcr.io/flow-container-registry/execution-corrupted:latest \
   205            gcr.io/flow-container-registry/verification-corrupted:latest > flow-docker-images.tar
   206        - name: Cache Docker images
   207          uses: actions/cache@v3
   208          with:
   209            path: flow-docker-images.tar
   210            # use the workflow run id as part of the cache key to ensure these docker images will only be used for a single workflow run
   211            key: flow-docker-images-${{ hashFiles('**/Dockerfile') }}-${{ github.run_id }}
   212  
   213    integration-test:
   214      name: Integration Tests
   215      needs: docker-build
   216      strategy:
   217        fail-fast: false
   218        matrix:
   219          include:
   220            - name: Access Cohort1 Integration Tests
   221              make: make -C integration access-cohort1-tests
   222              runner: buildjet-4vcpu-ubuntu-2204
   223            - name: Access Cohort2 Integration Tests
   224              make: make -C integration access-cohort2-tests
   225              runner: ubuntu-latest
   226            - name: Access Cohort3 Integration Tests
   227              make: make -C integration access-cohort3-tests
   228              runner: ubuntu-latest
   229              # test suite has single test which is flaky and needs to be fixed - reminder here to put it back when it's fixed
   230  #          - name: BFT (Framework) Integration Tests
   231  #            make: make -C integration bft-framework-tests
   232  #            runner: ubuntu-latest
   233            - name: BFT (Protocol) Integration Tests
   234              make: make -C integration bft-protocol-tests
   235              runner: buildjet-8vcpu-ubuntu-2204
   236            - name: BFT (Gossipsub) Integration Tests
   237              make: make -C integration bft-gossipsub-tests
   238              runner: ubuntu-latest
   239            - name: Collection Integration Tests
   240              make: make -C integration collection-tests
   241              runner: ubuntu-latest
   242            - name: Consensus Integration Tests
   243              make: make -C integration consensus-tests
   244              runner: ubuntu-latest
   245            - name: Epoch Cohort1 Integration Tests
   246              make: make -C integration epochs-cohort1-tests
   247              runner: buildjet-8vcpu-ubuntu-2204
   248            - name: Epoch Cohort2 Integration Tests
   249              make: make -C integration epochs-cohort2-tests
   250              runner: buildjet-4vcpu-ubuntu-2204
   251            - name: Execution Integration Tests
   252              make: make -C integration execution-tests
   253              runner: ubuntu-latest
   254            - name: Ghost Integration Tests
   255              make: make -C integration ghost-tests
   256              runner: ubuntu-latest
   257            - name: MVP Integration Tests
   258              make: make -C integration mvp-tests
   259              runner: ubuntu-latest
   260            - name: Network Integration Tests
   261              make: make -C integration network-tests
   262              runner: ubuntu-latest
   263            - name: Verification Integration Tests
   264              make: make -C integration verification-tests
   265              runner: ubuntu-latest
   266            - name: Upgrade Integration Tests
   267              make: make -C integration upgrades-tests
   268              runner: ubuntu-latest
   269      runs-on: ${{ matrix.runner }}
   270      steps:
   271      - name: Checkout repo
   272        uses: actions/checkout@v3
   273        with:
   274            # all tags are needed for integration tests
   275            fetch-depth: 0
   276      - name: Setup Go
   277        uses: actions/setup-go@v4
   278        timeout-minutes: 10 # fail fast. sometimes this step takes an extremely long time
   279        with:
   280          go-version: ${{ env.GO_VERSION }}
   281          cache: true
   282      - name: Load cached Docker images
   283        uses: actions/cache@v3
   284        with:
   285          path: flow-docker-images.tar
   286          # use the same cache key as the docker-build job
   287          key: flow-docker-images-${{ hashFiles('**/Dockerfile') }}-${{ github.run_id }}
   288      - name: Load Docker images
   289        run: docker load -i flow-docker-images.tar
   290      - name: Run tests (${{ matrix.name }})
   291        # TODO(rbtz): re-enable when we fix exisiting races.
   292        #env:
   293        #  RACE_DETECTOR: 1
   294        uses: nick-fields/retry@v2
   295        with:
   296          timeout_minutes: 35
   297          max_attempts: 5
   298          command: VERBOSE=1 ${{ matrix.make }}