From 3b12788f8ccb08bda5f6959968de3a070496c1d4 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Mon, 27 Jun 2022 18:19:43 -0300 Subject: [PATCH 1/8] feat: make tests run in parallel --- .github/workflows/pr.yaml | 109 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 183f2c9d..6653f16c 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -30,8 +30,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build-and-test: - name: Build and test + lint: + name: Lint runs-on: ubuntu-latest steps: - name: Checkout @@ -57,12 +57,37 @@ jobs: version: ${{ env.PNPM_VERSION }} run_install: true - # Check lint as early as possible to avoid - # Long fail CI and fail on this step - name: Lint run: | pnpm lint + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: "https://registry.npmjs.org" + + - name: Cache PNPM modules + uses: actions/cache@v2 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}- + + - name: Setup PNPM + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ env.PNPM_VERSION }} + run_install: true + - name: Install toolchain uses: actions-rs/toolchain@v1 with: @@ -71,6 +96,7 @@ jobs: override: true # selecting a toolchain either by action or manual `rustup` calls should happen # before the cache plugin, as it uses the current rustc version as its cache key + - uses: Swatinem/rust-cache@v1 - name: Set git config @@ -108,7 +134,7 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - + # Make github action to use the latest version of # docker compose without it docker compose down # has issues with memory nil pointer @@ -130,6 +156,79 @@ jobs: run: | pnpm ci:test:coverage + end-to-end-test: + name: Test E2E + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + registry-url: "https://registry.npmjs.org" + + - name: Cache PNPM modules + uses: actions/cache@v2 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}- + + - name: Setup PNPM + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ env.PNPM_VERSION }} + run_install: true + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ env.RUST_VERSION }} + override: true + # selecting a toolchain either by action or manual `rustup` calls should happen + # before the cache plugin, as it uses the current rustc version as its cache key + + - uses: Swatinem/rust-cache@v1 + + - name: Set git config + run: | + git config --global core.bigfilethreshold 100m + + - name: Install Forc + run: | + curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ env.FORC_VERSION }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz + tar -xvf forc.tar.gz + chmod +x forc-binaries/forc + mv forc-binaries/forc /usr/local/bin/forc + + - name: Setup Docker + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Make github action to use the latest version of + # docker compose without it docker compose down + # has issues with memory nil pointer + # https://github.com/docker/compose/pull/9354 + - name: Install Compose + uses: ndeloof/install-compose-action@v0.0.1 + with: + version: v${{ env.COMPOSE_VERSION }} + + - name: Docker info + run: | + docker info + + - name: Setup scripts + run: | + pnpm scripts:setup + # using same dependencies from cypress/browsers:node16.5.0-chrome97-ff96 ... # not using directly the container because we still need ubuntu-latest preset - name: Install Cypress Dependencies From 052fbc66446774e16fa2ea32ca90bf6991805698 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Mon, 27 Jun 2022 18:40:03 -0300 Subject: [PATCH 2/8] chore: rename action --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 6653f16c..4d6f1a5a 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -156,7 +156,7 @@ jobs: run: | pnpm ci:test:coverage - end-to-end-test: + e2e-test: name: Test E2E runs-on: ubuntu-latest steps: From b96ff59ee642f85a22a4a74f4b7770e636884cf5 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Mon, 27 Jun 2022 19:07:07 -0300 Subject: [PATCH 3/8] chore: remove debugging --- .github/workflows/pr.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 4d6f1a5a..50ccddf5 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -275,5 +275,6 @@ jobs: # Recommended: pass the GitHub token lets this action correctly # determine the unique run id necessary to re-run the checks GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DEBUG: "cypress:server:*" + # debugging make tests run slow. only include if you really need to track issues + # DEBUG: "cypress:server:*" NODE_ENV: "test" From 58d3012407a9893241919992a324d344794e6ff4 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Mon, 27 Jun 2022 22:42:02 -0300 Subject: [PATCH 4/8] feat: use composite actions to centralize code --- .github/setup-docker/action.yml | 32 +++++ .github/setup-node/action.yml | 30 +++++ .github/setup-rust/action.yml | 36 ++++++ .github/workflows/deploy-contracts.yml | 47 +------ .github/workflows/gh-pages.yml | 27 +--- .github/workflows/pr.yaml | 172 +++---------------------- 6 files changed, 118 insertions(+), 226 deletions(-) create mode 100644 .github/setup-docker/action.yml create mode 100644 .github/setup-node/action.yml create mode 100644 .github/setup-rust/action.yml diff --git a/.github/setup-docker/action.yml b/.github/setup-docker/action.yml new file mode 100644 index 00000000..05501dd7 --- /dev/null +++ b/.github/setup-docker/action.yml @@ -0,0 +1,32 @@ +name: 'Setup Docker' +inputs: + compose-version: + description: 'Docker-compose version' + default: 2.6.0 + password: + description: 'Password' + required: true +runs: + using: "composite" + steps: + - name: Setup Docker + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ inputs.password }} + + # Make github action to use the latest version of + # docker compose without it docker compose down + # has issues with memory nil pointer + # https://github.com/docker/compose/pull/9354 + - name: Install Compose + uses: ndeloof/install-compose-action@v0.0.1 + with: + version: v${{ inputs.compose-version }} + + - name: Docker info + run: | + docker info + shell: + bash \ No newline at end of file diff --git a/.github/setup-node/action.yml b/.github/setup-node/action.yml new file mode 100644 index 00000000..440a2428 --- /dev/null +++ b/.github/setup-node/action.yml @@ -0,0 +1,30 @@ +name: 'Setup Node.js env' +inputs: + node-version: + description: 'Node version' + default: 16 + pnpm-version: + description: 'PNPM version' + default: 7.0.0 +runs: + using: "composite" + steps: + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ inputs.node-version }} + registry-url: "https://registry.npmjs.org" + + - name: Cache PNPM modules + uses: actions/cache@v2 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}- + + - name: Setup PNPM + uses: pnpm/action-setup@v2.1.0 + with: + version: ${{ inputs.pnpm-version }} + run_install: true \ No newline at end of file diff --git a/.github/setup-rust/action.yml b/.github/setup-rust/action.yml new file mode 100644 index 00000000..cf0ffaa9 --- /dev/null +++ b/.github/setup-rust/action.yml @@ -0,0 +1,36 @@ +name: 'Setup Rust env' +inputs: + rust-version: + description: 'Rust version' + default: 1.61.0 + forc-version: + description: 'Forc version' + default: 0.16.1 +runs: + using: "composite" + steps: + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ inputs.rust-version }} + # selecting a toolchain either by action or manual `rustup` calls should happen + # before the cache plugin, as it uses the current rustc version as its cache key + override: true + + - uses: Swatinem/rust-cache@v1 + + - name: Set git config + run: | + git config --global core.bigfilethreshold 100m + shell: + bash + + - name: Install Forc + run: | + curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ inputs.forc-version }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz + tar -xvf forc.tar.gz + chmod +x forc-binaries/forc + mv forc-binaries/forc /usr/local/bin/forc + shell: + bash \ No newline at end of file diff --git a/.github/workflows/deploy-contracts.yml b/.github/workflows/deploy-contracts.yml index 9e44e4b0..0c941d7c 100644 --- a/.github/workflows/deploy-contracts.yml +++ b/.github/workflows/deploy-contracts.yml @@ -74,50 +74,9 @@ jobs: name: Build and deploy runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.RUST_VERSION }} - override: true - # selecting a toolchain either by action or manual `rustup` calls should happen - # before the cache plugin, as it uses the current rustc version as its cache key - - uses: Swatinem/rust-cache@v1 - - - name: Set git config - run: | - git config --global core.bigfilethreshold 100m - - - name: Install Forc - run: | - curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ env.FORC_VERSION }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz - tar -xvf forc.tar.gz - chmod +x forc-binaries/forc - mv forc-binaries/forc /usr/local/bin/forc - shell: bash - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - registry-url: "https://registry.npmjs.org" - - - name: Cache PNPM modules - uses: actions/cache@v2 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}- - - - name: Setup PNPM - uses: pnpm/action-setup@v2.1.0 - with: - version: ${{ env.PNPM_VERSION }} - run_install: true + - uses: actions/checkout@v3 + - uses: ./.github/setup-node + - uses: ./.github/setup-rust - name: Setup scripts run: | diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 2c2819eb..66a3214b 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -4,36 +4,13 @@ on: release: types: [published] -env: - NODE_VERSION: "16" - jobs: deploy: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: "16" - registry-url: "https://registry.npmjs.org" - - - name: Cache PNPM modules - uses: actions/cache@v2 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}- - - - name: Setup PNPM - uses: pnpm/action-setup@v2.1.0 - with: - version: 7.0.0 - run_install: true + - uses: actions/checkout@v3 + - uses: ./.github/setup-node - name: Build env: diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 50ccddf5..aa45c3d9 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -4,13 +4,6 @@ on: pull_request: types: [opened, synchronize, edited, closed] -env: - RUST_VERSION: 1.61.0 - FORC_VERSION: 0.16.1 - NODE_VERSION: 16 - PNPM_VERSION: 7.0.0 - COMPOSE_VERSION: 2.6.0 - jobs: cancel-previous-run: name: Cancel previous actions @@ -30,32 +23,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + lint: name: Lint runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - registry-url: "https://registry.npmjs.org" - - - name: Cache PNPM modules - uses: actions/cache@v2 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}- - - - name: Setup PNPM - uses: pnpm/action-setup@v2.1.0 - with: - version: ${{ env.PNPM_VERSION }} - run_install: true + - uses: actions/checkout@v3 + - uses: ./.github/setup-node - name: Lint run: | @@ -65,50 +39,12 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - registry-url: "https://registry.npmjs.org" - - - name: Cache PNPM modules - uses: actions/cache@v2 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}- - - - name: Setup PNPM - uses: pnpm/action-setup@v2.1.0 - with: - version: ${{ env.PNPM_VERSION }} - run_install: true - - - name: Install toolchain - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: ./.github/setup-node + - uses: ./.github/setup-rust + - uses: ./.github/setup-docker with: - profile: minimal - toolchain: ${{ env.RUST_VERSION }} - override: true - # selecting a toolchain either by action or manual `rustup` calls should happen - # before the cache plugin, as it uses the current rustc version as its cache key - - - uses: Swatinem/rust-cache@v1 - - - name: Set git config - run: | - git config --global core.bigfilethreshold 100m - - - name: Install Forc - run: | - curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ env.FORC_VERSION }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz - tar -xvf forc.tar.gz - chmod +x forc-binaries/forc - mv forc-binaries/forc /usr/local/bin/forc + password: ${{ secrets.GITHUB_TOKEN }} # As contracts are really Heavy to build # and test we only test it when some @@ -128,26 +64,6 @@ jobs: run: | ./scripts/test-contracts.sh - - name: Setup Docker - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Make github action to use the latest version of - # docker compose without it docker compose down - # has issues with memory nil pointer - # https://github.com/docker/compose/pull/9354 - - name: Install Compose - uses: ndeloof/install-compose-action@v0.0.1 - with: - version: v${{ env.COMPOSE_VERSION }} - - - name: Docker info - run: | - docker info - - name: Setup scripts run: | pnpm scripts:setup @@ -156,74 +72,16 @@ jobs: run: | pnpm ci:test:coverage - e2e-test: + end-to-end-test: name: Test E2E runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v2 - with: - node-version: ${{ env.NODE_VERSION }} - registry-url: "https://registry.npmjs.org" - - - name: Cache PNPM modules - uses: actions/cache@v2 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}- - - - name: Setup PNPM - uses: pnpm/action-setup@v2.1.0 - with: - version: ${{ env.PNPM_VERSION }} - run_install: true - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.RUST_VERSION }} - override: true - # selecting a toolchain either by action or manual `rustup` calls should happen - # before the cache plugin, as it uses the current rustc version as its cache key - - - uses: Swatinem/rust-cache@v1 - - - name: Set git config - run: | - git config --global core.bigfilethreshold 100m - - - name: Install Forc - run: | - curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ env.FORC_VERSION }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz - tar -xvf forc.tar.gz - chmod +x forc-binaries/forc - mv forc-binaries/forc /usr/local/bin/forc - - - name: Setup Docker - uses: docker/login-action@v2 + - uses: actions/checkout@v3 + - uses: ./.github/setup-node + - uses: ./.github/setup-rust + - uses: ./.github/setup-docker with: - registry: ghcr.io - username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - # Make github action to use the latest version of - # docker compose without it docker compose down - # has issues with memory nil pointer - # https://github.com/docker/compose/pull/9354 - - name: Install Compose - uses: ndeloof/install-compose-action@v0.0.1 - with: - version: v${{ env.COMPOSE_VERSION }} - - - name: Docker info - run: | - docker info - name: Setup scripts run: | @@ -275,6 +133,6 @@ jobs: # Recommended: pass the GitHub token lets this action correctly # determine the unique run id necessary to re-run the checks GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # debugging make tests run slow. only include if you really need to track issues - # DEBUG: "cypress:server:*" NODE_ENV: "test" + # debugging seems to make tests slower randomly. you can include if you need to track issues in CI + # DEBUG: "cypress:server:*" \ No newline at end of file From 810c8c4229bd12f746bdf64511cd634c03787275 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Mon, 27 Jun 2022 23:22:10 -0300 Subject: [PATCH 5/8] chore: include lint before tests --- .github/workflows/pr.yaml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index aa45c3d9..9c5c0ac6 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,24 +23,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/setup-node - - - name: Lint - run: | - pnpm lint - test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: ./.github/setup-node + - run: pnpm lint - uses: ./.github/setup-rust - uses: ./.github/setup-docker with: @@ -78,6 +67,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ./.github/setup-node + - run: pnpm lint - uses: ./.github/setup-rust - uses: ./.github/setup-docker with: From 2578ceafaee704f022d3bed3fcf7b65b2787cf6c Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Mon, 27 Jun 2022 23:55:39 -0300 Subject: [PATCH 6/8] fix: stop tests if lint fail --- .github/workflows/pr.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 9c5c0ac6..0702741b 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -23,9 +23,18 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/setup-node + - run: pnpm lint + test: name: Test runs-on: ubuntu-latest + continue-on-error: false steps: - uses: actions/checkout@v3 - uses: ./.github/setup-node @@ -64,6 +73,7 @@ jobs: end-to-end-test: name: Test E2E runs-on: ubuntu-latest + continue-on-error: false steps: - uses: actions/checkout@v3 - uses: ./.github/setup-node From 0ef30b1b66dca11217739f821769aaf88a6a0d40 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Tue, 28 Jun 2022 00:06:38 -0300 Subject: [PATCH 7/8] chore: remove dup lints --- .github/workflows/pr.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0702741b..f5eab1ba 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -38,7 +38,6 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ./.github/setup-node - - run: pnpm lint - uses: ./.github/setup-rust - uses: ./.github/setup-docker with: @@ -77,7 +76,6 @@ jobs: steps: - uses: actions/checkout@v3 - uses: ./.github/setup-node - - run: pnpm lint - uses: ./.github/setup-rust - uses: ./.github/setup-docker with: From e4bbfe749869cda90e1b542857cb9e21971f87ad Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Tue, 28 Jun 2022 12:42:04 -0300 Subject: [PATCH 8/8] chore: remove comment --- .github/workflows/pr.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index f5eab1ba..472e4764 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -131,6 +131,4 @@ jobs: # Recommended: pass the GitHub token lets this action correctly # determine the unique run id necessary to re-run the checks GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_ENV: "test" - # debugging seems to make tests slower randomly. you can include if you need to track issues in CI - # DEBUG: "cypress:server:*" \ No newline at end of file + NODE_ENV: "test" \ No newline at end of file