Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

feat: make tests run in parallel #352

Merged
merged 9 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/setup-docker/action.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
version: v${{ inputs.compose-version }}

- name: Docker info
run: |
docker info
shell:
bash
30 changes: 30 additions & 0 deletions .github/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
version: ${{ inputs.pnpm-version }}
run_install: true
36 changes: 36 additions & 0 deletions .github/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -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
47 changes: 3 additions & 44 deletions .github/workflows/deploy-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
version: ${{ env.PNPM_VERSION }}
run_install: true
- uses: actions/checkout@v3
- uses: ./.github/setup-node
- uses: ./.github/setup-rust

- name: Setup scripts
run: |
Expand Down
27 changes: 2 additions & 25 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
with:
version: 7.0.0
run_install: true
- uses: actions/checkout@v3
- uses: ./.github/setup-node

- name: Build
env:
Expand Down
110 changes: 33 additions & 77 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,59 +23,25 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-and-test:
name: Build and test
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/[email protected]
with:
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
- uses: actions/checkout@v3
- uses: ./.github/setup-node
- run: pnpm lint

- name: Install toolchain
uses: actions-rs/toolchain@v1
test:
name: Test
runs-on: ubuntu-latest
continue-on-error: false
steps:
- 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
Expand All @@ -102,26 +61,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/[email protected]
with:
version: v${{ env.COMPOSE_VERSION }}

- name: Docker info
run: |
docker info

- name: Setup scripts
run: |
pnpm scripts:setup
Expand All @@ -130,6 +69,22 @@ jobs:
run: |
pnpm ci:test:coverage

end-to-end-test:
name: Test E2E
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v3
- uses: ./.github/setup-node
- uses: ./.github/setup-rust
- uses: ./.github/setup-docker
with:
password: ${{ secrets.GITHUB_TOKEN }}

- 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
Expand Down Expand Up @@ -176,5 +131,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:*"
NODE_ENV: "test"
# debugging seems to make tests slower randomly. you can include if you need to track issues in CI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove it if will not be required

# DEBUG: "cypress:server:*"