mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-09 14:48:12 -05:00
chore: optimize pull-requests workflow (#765)
* chore: optimize pull-requests workflow * fix: quote glob pattern * fix: append `$` to variables in workflow * chore: include `yaml` files in lintstaged format check * feat: detect to_format or to_lint changed files * feat: run test workflow steps conditionally * Update .github/workflows/pull-requests.yml Co-authored-by: Daehyun Paik <paik@a30a.dev> * Update .github/workflows/pull-requests.yml Co-authored-by: Daehyun Paik <paik@a30a.dev> * fix: build utils before contracts * fix: build identity pkg before running contracts tests * fix: need to quote `true` * fix: build group pkg before running contracts tests * fix: build `{group,identity,proof}` before running circuits tests * fix: build `proof` pkg before running contracts tests * fix: build utils before testing circuits * fix: build `utils` before `subgraph` pkg --------- Co-authored-by: Daehyun Paik <paik@a30a.dev>
This commit is contained in:
120
.github/workflows/pull-requests.yml
vendored
120
.github/workflows/pull-requests.yml
vendored
@@ -22,20 +22,57 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build libraries
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files_yaml: |
|
||||
circuits:
|
||||
- packages/circuits/**/*.{circom,json,ts}
|
||||
contracts:
|
||||
- packages/contracts/**/*.{js,json,ts,sol}
|
||||
docs:
|
||||
- apps/docs/**/*
|
||||
libraries:
|
||||
- packages/**/*.{js,json,ts}
|
||||
- '!packages/{circuits,contracts}/**/*'
|
||||
subgraph:
|
||||
- apps/subgraph/**/*
|
||||
to_format:
|
||||
- '**/*.{cjs,js,json,jsx,md,mdx,sol,ts,tsx,yaml,yml}'
|
||||
to_lint:
|
||||
- '**/*.{cjs,js,jsx,ts,tsx}'
|
||||
|
||||
- if: steps.changed-files.outputs.contracts_any_changed == 'true'
|
||||
name: Compile and lint contracts
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn compile:contracts
|
||||
yarn workspace semaphore-contracts lint
|
||||
|
||||
- if: steps.changed-files.outputs.docs_any_changed == 'true'
|
||||
name: Build and format docs
|
||||
run: |
|
||||
yarn workspace semaphore-docs build
|
||||
yarn workspace semaphore-docs format
|
||||
|
||||
- if: steps.changed-files.outputs.libraries_any_changed == 'true'
|
||||
name: Build libraries
|
||||
run: yarn build:libraries
|
||||
|
||||
- name: Compile contracts
|
||||
run: yarn compile:contracts
|
||||
- if: steps.changed-files.outputs.subgraph_any_changed == 'true'
|
||||
name: Build subgraph
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn build:subgraph
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
- if: steps.changed-files.outputs.to_format_any_changed == 'true'
|
||||
name: Format
|
||||
run: yarn run prettier --check ${{ steps.changed-files.outputs.to_format_all_changed_files }}
|
||||
|
||||
- name: Format
|
||||
run: yarn format
|
||||
|
||||
- name: Run Eslint
|
||||
run: yarn lint
|
||||
- if: steps.changed-files.outputs.to_lint_any_changed == 'true'
|
||||
name: Run Eslint
|
||||
run: yarn run eslint ${{ steps.changed-files.outputs.to_lint_all_changed_files }} --ext .cjs,.js,.jsx,.ts,.tsx
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -49,24 +86,55 @@ jobs:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
|
||||
# https://github.com/iden3/circuits/blob/8fffb6609ecad0b7bcda19bb908bdb544bdb3cf7/.github/workflows/main.yml#L18-L22
|
||||
# https://stackoverflow.com/a/78377916
|
||||
- name: Setup Circom deps
|
||||
run: |
|
||||
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
|
||||
sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
|
||||
|
||||
- name: Setup Circom
|
||||
run: wget https://github.com/iden3/circom/releases/latest/download/circom-linux-amd64 && sudo mv ./circom-linux-amd64 /usr/bin/circom && sudo chmod +x /usr/bin/circom
|
||||
|
||||
- name: Install dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Build libraries
|
||||
run: yarn build:libraries
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files_yaml: |
|
||||
circuits:
|
||||
- packages/circuits/**/*.{circom,json,ts}
|
||||
contracts:
|
||||
- packages/contracts/**/*.{js,json,ts,sol}
|
||||
libraries:
|
||||
- packages/**/*.{js,json,ts}
|
||||
- '!packages/{circuits,contracts}/**/*'
|
||||
subgraph:
|
||||
- apps/subgraph/**/*
|
||||
|
||||
- name: Build subgraph
|
||||
run: yarn build:subgraph
|
||||
# https://github.com/iden3/circuits/blob/8fffb6609ecad0b7bcda19bb908bdb544bdb3cf7/.github/workflows/main.yml#L18-L22
|
||||
# https://stackoverflow.com/a/78377916
|
||||
- if: steps.changed-files.outputs.circuits_any_changed == 'true'
|
||||
name: Setup Circom and Test circuits
|
||||
run: |
|
||||
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
|
||||
sudo apt-get update && sudo apt-get install -y wget nlohmann-json3-dev libgmp-dev nasm g++ build-essential
|
||||
wget https://github.com/iden3/circom/releases/latest/download/circom-linux-amd64 && sudo mv ./circom-linux-amd64 /usr/bin/circom && sudo chmod +x /usr/bin/circom
|
||||
yarn workspace @semaphore-protocol/group build
|
||||
yarn workspace @semaphore-protocol/identity build
|
||||
yarn workspace @semaphore-protocol/proof build
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn test:circuits
|
||||
|
||||
- name: Test contracts, libraries, circuits and subgraph
|
||||
run: yarn test
|
||||
- if: steps.changed-files.outputs.contracts_any_changed == 'true'
|
||||
name: Build and Test contracts
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/group build
|
||||
yarn workspace @semaphore-protocol/identity build
|
||||
yarn workspace @semaphore-protocol/proof build
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn compile:contracts
|
||||
yarn test:contracts
|
||||
|
||||
- if: steps.changed-files.outputs.libraries_any_changed == 'true'
|
||||
name: Build and Test libraries
|
||||
run: yarn build:libraries && yarn test:libraries
|
||||
|
||||
- if: steps.changed-files.outputs.subgraph_any_changed == 'true'
|
||||
name: Build and Test Subgraph
|
||||
run: |
|
||||
yarn workspace @semaphore-protocol/utils build
|
||||
yarn build:subgraph
|
||||
yarn test:subgraph
|
||||
|
||||
Reference in New Issue
Block a user