Skip to content

Workflow caching with nix & faster pre-commit hook (#1929) #809

Workflow caching with nix & faster pre-commit hook (#1929)

Workflow caching with nix & faster pre-commit hook (#1929) #809

Workflow file for this run

name: CI | Canary (Dev)
on:
push:
branches: ["dev"]
paths:
- ".github/workflows/ci.canary.yml"
- ".github/workflows/call.*.yml"
- "package.json"
- "yarn.lock"
- "packages/**"
- "codecov.yml"
# - "**.md" are commented out because docs updates should go into the packages
jobs:
check:
name: Checking what packages need to be built
runs-on: ubuntu-latest
outputs:
build_subgraph: ${{ env.BUILD_SUBGRAPH }}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v13
- name: Initialize nix dev shell
run: |
node --version
yarn --version
shellcheck --version
actionlint --version
- name: Show contexts
env:
HEAD_REF: ${{ github.head_ref }}
GITHUB_REF: ${{ github.ref }}
run: |
echo github.event_name: ${{ github.event_name }}
echo github.sha: ${{ github.sha }}
echo github.repository: ${{ github.repository }}
echo github.ref: "$GITHUB_REF"
echo github.head_ref: "$HEAD_REF"
echo github.base_ref: ${{ github.base_ref }}
- name: Run global lint
run: |
npm run lint:shellcheck
npm run lint:actionlint
- name: Create build set
run: tasks/create-build-set.sh ${{ github.sha }} dev origin
test-spec-haskell:
uses: ./.github/workflows/call.test-spec-haskell.yml
name: Build and Test Spec Haskell (Canary Branch)
needs: [check]
test-solidity-semantic-money:
name: Build and Test Solidity Semantic Money (Canary Branch)
uses: ./.github/workflows/call.test-solidity-semantic-money.yml
needs: [check]
test-ethereum-contracts:
name: Test ethereum-contracts (Canary Branch)
uses: ./.github/workflows/call.test-ethereum-contracts.yml
needs: [check]
with:
run-coverage-tests: false
coverage-ethereum-contracts:
name: Coverage test ethereum-contracts (Canary Branch)
uses: ./.github/workflows/call.test-ethereum-contracts.yml
needs: [check]
with:
run-coverage-tests: true
test-hot-fuzz:
uses: ./.github/workflows/call.test-hot-fuzz.yml
name: Hot Fuzz (Development Branch)
needs: [check]
test-sdk-core:
uses: ./.github/workflows/call.test-sdk-core.yml
name: Build and Test SDK-Core (Development Branch)
needs: [check]
with:
subgraph-release: local
subgraph-endpoint: http://localhost:8000/subgraphs/name/superfluid-test
run-coverage-tests: false
coverage-sdk-core:
uses: ./.github/workflows/call.test-sdk-core.yml
name: Build and Test SDK-Core Coverage (Canary Branch)
needs: [check]
with:
subgraph-release: local
subgraph-endpoint: http://localhost:8000/subgraphs/name/superfluid-test
run-coverage-tests: true
test-subgraph:
uses: ./.github/workflows/call.test-local-subgraph.yml
name: Build and Test Subgraph (Development Branch)
needs: [check]
test-automation-contracts:
uses: ./.github/workflows/call.test-automation-contracts.yml
name: Build and Test Automation Contracts (Canary Branch)
needs: [check]
# deploy subgraph if changes are made, we can call this every time, but we won't actually do any deployments
# if the IPFS hash generated stays the same (no mapping logic changes)
deploy-subgraph-changes:
uses: ./.github/workflows/call.deploy-subgraph.yml
name: "Deploy Hosted Service Subgraph to dev endpoints on all networks"
needs: [check, test-subgraph]
if: needs.check.outputs.build_subgraph
with:
vendor: graph
deployment_env: dev
network: "all"
secrets:
THE_GRAPH_ACCESS_TOKEN: ${{ secrets.THE_GRAPH_ACCESS_TOKEN }}
upload-coverage-reports:
name: Upload Coverage Reports (Feature Branch)
uses: ./.github/workflows/call.upload-coverage-reports.yml
needs: [coverage-ethereum-contracts, coverage-sdk-core]
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
all-packages-tested:
name: All packages tested (Dev Branch)
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-not-requiring-successful-dependent-jobs
if: ${{ always() }}
needs: [ test-spec-haskell
, test-solidity-semantic-money
, test-ethereum-contracts, coverage-ethereum-contracts
, test-hot-fuzz
, test-sdk-core, coverage-sdk-core
, test-subgraph
, test-automation-contracts
]
steps:
- name: Test Results
run: |
function check_result() {
local package_name="$1"
local result="$2"
if [ "$result" == "skipped" ];then
echo "Skipped $package_name package."
else
echo "Checking if $package_name package test passes..."
test "$result" == "success"
echo "Passed."
fi
}
check_result spec-haskell ${{ needs.test-spec-haskell.result }}
check_result solidity-semantic-money ${{ needs.test-solidity-semantic-money.result }}
check_result test-ethereum-contracts ${{ needs.test-ethereum-contracts.result }}
check_result coverage-ethereum-contracts ${{ needs.coverage-ethereum-contracts.result }}
check_result hot-fuzz ${{ needs.test-hot-fuzz.result }}
check_result test-sdk-core ${{ needs.test-sdk-core.result }}
check_result coverage-sdk-core ${{ needs.coverage-sdk-core.result }}
check_result subgraph ${{ needs.test-subgraph.result }}
check_result automation-contracts ${{ needs.test-automation-contracts.result }}
publish-npm-packages:
name: Publish canary packages to registries
permissions: write-all
needs: [all-packages-tested]
runs-on: ubuntu-latest
defaults:
run:
shell: nix develop .#ci-default -c bash -xe {0}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v13
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: |
yarn --cwd packages/sdk-core set-default-subgraph-release-tag
yarn build
env:
SUBGRAPH_RELEASE_TAG: dev
- name: Setup canary package versions locally
run: |
shortRev=$(git rev-parse --short ${{ github.sha }})
preId=dev.${shortRev}
yarn lerna version prerelease --yes --no-git-tag-version --preid "${preId}"
- name: Publish to npm
run: |
tasks/npm-publish.sh packages/ethereum-contracts/ dev --verbose
tasks/npm-publish.sh packages/sdk-core/ dev --verbose
tasks/npm-publish.sh packages/sdk-redux/ dev --verbose
tasks/npm-publish.sh packages/metadata/ dev --verbose
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPMJS_TOKEN: ${{ secrets.NPMJS_TOKEN }}
publish-sdk-html-docs:
name: Publish canary HTML docs
needs: [all-packages-tested]
runs-on: ubuntu-latest
defaults:
run:
shell: nix develop .#ci-default -c bash -xe {0}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: superfluid-finance/build-scripts
path: build-scripts
- uses: DeterminateSystems/nix-installer-action@v13
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: |
yarn --cwd packages/sdk-core set-default-subgraph-release-tag
yarn build
env:
SUBGRAPH_RELEASE_TAG: dev
- name: Build HTML documentation of SDK-s
run: |
yarn --cwd packages/sdk-core doc:html
yarn --cwd packages/sdk-redux doc:html
- name: Upload sdk-core HTML documentation
uses: ./build-scripts/s3cloudfront-hosting/actions/sync
with:
local_build_dir: packages/sdk-core/dist/docs
aws_region: eu-west-2
aws_access_key_id: ${{ secrets.SITE_DEPLOYER_AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.SITE_DEPLOYER_AWS_SECRET_ACCESS_KEY }}
s3_uri: ${{ format('{0}sdk-core@dev', secrets.SITE_DEPLOYER_AWS_S3_DOCS_URI) }}
cloudfront_distribution_id: E3JEO5R14CT8IH
- name: Upload sdk-redux HTML documentation
uses: ./build-scripts/s3cloudfront-hosting/actions/sync
with:
local_build_dir: packages/sdk-redux/dist/docs
aws_region: eu-west-2
aws_access_key_id: ${{ secrets.SITE_DEPLOYER_AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.SITE_DEPLOYER_AWS_SECRET_ACCESS_KEY }}
s3_uri: ${{ format('{0}sdk-redux@dev', secrets.SITE_DEPLOYER_AWS_S3_DOCS_URI) }}
cloudfront_distribution_id: E3JEO5R14CT8IH
upgrade-contracts:
name: Upgrade ethereum-contracts on canary testnet (protocol release version "canary")
if: false # disable this for now
needs: [all-packages-tested]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
network: [optimism-sepolia]
defaults:
run:
shell: nix develop .#ci-default -c bash -xe {0}
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v13
- name: Build
run: |
yarn install --frozen-lockfile
yarn build
- name: Deploy to ${{ matrix.network }}
run: |
cd packages/ethereum-contracts
npx truffle exec --network ${{ matrix.network }} ops-scripts/deploy-test-environment.js
npx truffle exec --network ${{ matrix.network }} ops-scripts/info-print-contract-addresses.js : addresses.vars
tasks/etherscan-verify-framework.sh ${{ matrix.network }} addresses.vars
env:
RELEASE_VERSION: canary
OPTIMISM_SEPOLIA_MNEMONIC: ${{ secrets.BUILD_AGENT_MNEMONIC }}
OPTIMISM_SEPOLIA_PROVIDER_URL: ${{ secrets.OPTIMISM_SEPOLIA_PROVIDER_URL }}