github.com/koko1123/flow-go-1@v0.29.6/.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  
    18  env:
    19    GO_VERSION: 1.19
    20  
    21  concurrency: 
    22    group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
    23    cancel-in-progress: true
    24  
    25  jobs:
    26    golangci:
    27      strategy:
    28        fail-fast: false
    29        matrix:
    30          dir: [./, ./integration/, ./crypto/, ./insecure/]
    31      name: Lint
    32      runs-on: ubuntu-latest
    33      steps:
    34      - name: Checkout repo
    35        uses: actions/checkout@v3
    36      - name: Setup Go
    37        uses: actions/setup-go@v3
    38        with:
    39          go-version: ${{ env.GO_VERSION }}
    40          cache: true
    41      - name: Build relic
    42        run: make crypto_setup_gopath
    43      - name: Run go generate
    44        run: go generate
    45        working-directory: ${{ matrix.dir }}
    46      - name: Run golangci-lint
    47        uses: golangci/golangci-lint-action@v3
    48        with:
    49          # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
    50          version: v1.49
    51          args: -v --build-tags relic
    52          working-directory: ${{ matrix.dir }}
    53          # https://github.com/golangci/golangci-lint-action/issues/244
    54          skip-cache: true
    55  
    56    tidy:
    57      name: Tidy
    58      runs-on: ubuntu-latest
    59      steps:
    60        - name: Checkout repo
    61          uses: actions/checkout@v3
    62        - name: Setup Go
    63          uses: actions/setup-go@v3
    64          with:
    65            go-version: ${{ env.GO_VERSION }}
    66            cache: true
    67        - name: Run tidy
    68          run: make tidy
    69        - name: Emulator no relic check
    70          run: make emulator-norelic-check
    71  
    72    shell-check:
    73      name: ShellCheck
    74      runs-on: ubuntu-latest
    75      steps:
    76      - name: Checkout repo
    77        uses: actions/checkout@v3
    78      - name: Run ShellCheck
    79        uses: ludeeus/action-shellcheck@203a3fd018dfe73f8ae7e3aa8da2c149a5f41c33
    80        with:
    81          scandir: './crypto'
    82          ignore: 'relic'
    83  
    84    create-dynamic-test-matrix:
    85      name: Create Dynamic Test Matrix
    86      runs-on: ubuntu-latest
    87      outputs:
    88        dynamic-matrix: ${{ steps.set-test-matrix.outputs.dynamicMatrix }}
    89      steps:
    90        - name: Checkout repo
    91          uses: actions/checkout@v3
    92        - name: Setup Go
    93          uses: actions/setup-go@v3
    94          with:
    95            go-version: ${{ env.GO_VERSION }}
    96            cache: true
    97        - name: Set Test Matrix
    98          id: set-test-matrix
    99          run: go run utils/test_matrix/test_matrix.go access admin cmd consensus engine fvm ledger module network utils
   100  
   101    unit-test:
   102      name: Unit Tests (${{ matrix.targets.name }})
   103      needs: create-dynamic-test-matrix
   104      strategy:
   105        fail-fast: false
   106        matrix:
   107          targets: ${{ fromJSON(needs.create-dynamic-test-matrix.outputs.dynamic-matrix)}}
   108      # need to set image explicitly due to GitHub logging issue as described in https://github.com/onflow/flow-go/pull/3087#issuecomment-1234383202
   109      runs-on: ubuntu-20.04
   110      steps:
   111      - name: Checkout repo
   112        uses: actions/checkout@v3
   113      - name: Setup Go
   114        uses: actions/setup-go@v3
   115        with:
   116          go-version: ${{ env.GO_VERSION }}
   117          cache: true
   118      - name: Run tests (${{ matrix.targets.name }})
   119        if: github.actor != 'bors[bot]'
   120        uses: nick-invision/retry@v2
   121        with:
   122          timeout_minutes: 25
   123          max_attempts: 3
   124          command: VERBOSE=1 make -e GO_TEST_PACKAGES="${{ matrix.targets.packages }}" ci
   125  
   126        # TODO(rbtz): re-enable when we fix exisiting races.
   127        #env:
   128        #  RACE_DETECTOR: 1
   129      - name: Run tests (Bors)
   130        if: github.actor == 'bors[bot]'
   131        uses: nick-invision/retry@v2
   132        with:
   133          timeout_minutes: 25
   134          max_attempts: 3
   135          command: VERBOSE=1 make -e GO_TEST_PACKAGES="${{ matrix.targets.packages }}" ci
   136      - name: Upload coverage report
   137        uses: codecov/codecov-action@v3
   138        with:
   139          file: ./coverage.txt
   140          flags: unittests
   141          name: codecov-umbrella
   142  
   143    unit-test-modules:
   144      name: Unit Tests (Modules)
   145      strategy:
   146        fail-fast: false
   147        matrix:
   148          include:
   149            - name: crypto
   150              make1: -C crypto setup
   151              make2: unittest
   152              retries: 1
   153              race: 1
   154            - name: insecure
   155              make1: install-tools
   156              make2: test
   157              retries: 3
   158              race: 1
   159            - name: integration
   160              make1: install-tools
   161              make2: test
   162              retries: 3
   163              race: 0
   164      runs-on: ubuntu-latest
   165      steps:
   166        - name: Checkout repo
   167          uses: actions/checkout@v3
   168        - name: Setup Go
   169          uses: actions/setup-go@v3
   170          with:
   171            go-version: ${{ env.GO_VERSION }}
   172            cache: true
   173        - name: Run tests (${{ matrix.name }})
   174          if: github.actor != 'bors[bot]'
   175          env:
   176            RACE_DETECTOR: ${{ matrix.race }}
   177          # run `make1` target before running `make2` target inside each module's root
   178          run: |
   179            make ${{ matrix.make1 }}
   180            VERBOSE=1 make -C ${{ matrix.name }} ${{ matrix.make2 }}
   181        - name: Run tests (Bors)
   182          if: github.actor == 'bors[bot]'
   183          uses: nick-invision/retry@v2
   184          with:
   185            timeout_minutes: 25
   186            max_attempts: ${{ matrix.retries }}
   187            command: |
   188              make ${{ matrix.make1 }}
   189              VERBOSE=1 make -C ${{ matrix.name }} ${{ matrix.make2 }}
   190        - name: Upload coverage report
   191          uses: codecov/codecov-action@v3
   192          with:
   193            file: ./coverage.txt
   194            flags: unittests
   195            name: codecov-umbrella
   196  
   197    integration-test:
   198      name: Integration Tests
   199      strategy:
   200        fail-fast: false
   201        matrix:
   202          make:
   203            - make -C integration access-tests
   204            - make -C integration bft-tests
   205            - make -C integration collection-tests
   206            - make -C integration consensus-tests
   207            - make -C integration epochs-tests
   208            - make -C integration execution-tests
   209            - make -C integration ghost-tests
   210            - make -C integration mvp-tests
   211            - make -C integration network-tests
   212            - make -C integration verification-tests
   213      runs-on: ubuntu-latest
   214      steps:
   215      - name: Checkout repo
   216        uses: actions/checkout@v3
   217      - name: Setup Go
   218        uses: actions/setup-go@v3
   219        with:
   220          go-version: ${{ env.GO_VERSION }}
   221          cache: true
   222      - name: Build relic
   223        run: make crypto_setup_gopath
   224      - name: Docker build
   225        run: make docker-build-flow docker-build-flow-corrupt
   226      - name: Run tests
   227        if: github.actor != 'bors[bot]'
   228        run: VERBOSE=1 ${{ matrix.make }}
   229        # TODO(rbtz): re-enable when we fix exisiting races.
   230        #env:
   231        #  RACE_DETECTOR: 1
   232      - name: Run tests (Bors)
   233        if: github.actor == 'bors[bot]'
   234        uses: nick-invision/retry@v2
   235        with:
   236          timeout_minutes: 15
   237          max_attempts: 2
   238          command: ${{ matrix.make }}
   239  
   240    localnet-test:
   241      name: Localnet Compatibility Tests With Flow-CLI Client and Observer
   242      strategy:
   243        fail-fast: false
   244      runs-on: ubuntu-latest
   245      steps:
   246      - name: Checkout repo
   247        uses: actions/checkout@v3
   248      - name: Setup Go
   249        uses: actions/setup-go@v3
   250        with:
   251          go-version: ${{ env.GO_VERSION }}
   252          cache: true
   253      - name: Build relic and other tools
   254        run: make install-tools
   255      - name: Install Flow Client In Docker
   256        # This proved to be more reliable than installing it locally.
   257        run: cd integration/localnet && sh client/client.sh
   258      - name: Set up Localnet
   259        run: bash -c 'cd integration/localnet/ && make -e OBSERVER=2 bootstrap && make start-flow'
   260      - name: Ensure Observer is started
   261        run: docker ps -f name=localnet_observer_1_1 | grep localnet_observer
   262      - name: Get Client Version ensuring the client is provisioned
   263        run: docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n observer version
   264      - name: Wait for a default waiting period until a clean state
   265        # This will not cause flakiness.
   266        # The waiting time is a reasonable time to expect an observer to be responsive
   267        run: sleep 10
   268      - name: Get Status ensuring the access endpoint is online
   269        run: docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n access status
   270      - name: Wait for finalized blocks and check them
   271        run: docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n observer blocks get latest
   272      - name: Wait for finalized blocks and check them with Observer
   273        run: sleep 5 && docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n access blocks get latest && docker run --network host localnet-client /go/flow -f /go/flow-localnet.json -n observer blocks get latest
   274      - name: Stop localnet
   275        run: bash -c 'cd integration/localnet/ && make stop'