diff --git a/.github/actions/setup-workflow-base/action.yml b/.github/actions/setup-workflow-base/action.yml new file mode 100644 index 0000000000..73c4f97682 --- /dev/null +++ b/.github/actions/setup-workflow-base/action.yml @@ -0,0 +1,52 @@ +name: Setup Workflow Base +description: > + This sets up the base for a workflow, where: + + - nix is installed, + - cache is looked up, + - and nix dev shell is setup if cache is missed. + +inputs: + package-name: + description: Name of the package where input files are from + required: true + cache-key-prefix: + description: Cache key prefix to attach to the calculated input files hash + required: true + dev-shell-name: + description: Default shell to be used + +outputs: + cache-hit: + value: ${{ steps.cache.outputs.cache-hit }} + +runs: + using: composite + steps: + - uses: DeterminateSystems/nix-installer-action@v13 + + - name: Load the half-board nix module + id: hb + run: | + ./tasks/mk-cache-key.sh ./packages/${{ inputs.package-name }} > cache.json + jq . cache.json + key_prefix="${{ inputs.cache-key-prefix }}" + path=$(jq '.outputs | join("\n")' cache.json) + hash=$(jq -r .hash cache.json) + echo "path=$path" >> "$GITHUB_OUTPUT" + echo "key=${key_prefix}${hash}" >> "$GITHUB_OUTPUT" + shell: nix develop .#mk-cache-key -c bash -xe {0} + + - name: Lookup cache + id: cache + uses: actions/cache@v4 + with: + path: ${{ fromJSON(steps.hb.outputs.path) }} + key: ${{ steps.hb.outputs.key }} + + - name: Initialize nix dev shell + if: steps.cache.outputs.cache-hit != 'true' + run: | + node --version + yarn --version + shell: nix develop .#${{ inputs.dev-shell-name }} -c bash -xe {0} diff --git a/.github/workflows/call.check-query-schema-against-subgraph.yml b/.github/workflows/call.check-query-schema-against-subgraph.yml index 13275c31ec..b5b45fb748 100644 --- a/.github/workflows/call.check-query-schema-against-subgraph.yml +++ b/.github/workflows/call.check-query-schema-against-subgraph.yml @@ -23,9 +23,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: "Install dependencies" run: yarn install --frozen-lockfile diff --git a/.github/workflows/call.deploy-subgraph.yml b/.github/workflows/call.deploy-subgraph.yml index 854ecc2a0a..a4503a6725 100644 --- a/.github/workflows/call.deploy-subgraph.yml +++ b/.github/workflows/call.deploy-subgraph.yml @@ -69,9 +69,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: "Install dependencies" run: yarn install --frozen-lockfile diff --git a/.github/workflows/call.test-automation-contracts.yml b/.github/workflows/call.test-automation-contracts.yml index b8cf75784b..04bf4d4023 100644 --- a/.github/workflows/call.test-automation-contracts.yml +++ b/.github/workflows/call.test-automation-contracts.yml @@ -9,33 +9,44 @@ jobs: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18, 20] - defaults: run: - shell: nix develop .#ci-node${{ matrix.node-version }} -c bash -xe {0} + shell: nix develop .#ci-default -c bash -xe {0} steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + package-name: automation-contracts + cache-key-prefix: automation-contracts- + dev-shell-name: ci-default - - name: Install, lint and build + - name: Install dependencies + if: steps.base.outputs.cache-hit != 'true' run: | yarn install --frozen-lockfile + solc --version + forge --version + + - name: Lint and build + if: steps.base.outputs.cache-hit != 'true' + run: | yarn lint yarn build - name: Test automation-contracts-scheduler + if: steps.base.outputs.cache-hit != 'true' run: | - echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV yarn workspace scheduler test + env: + FOUNDRY_PROFILE: ci - name: Test automation-contracts-autowrap + if: steps.base.outputs.cache-hit != 'true' run: | - echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV yarn workspace autowrap test + env: + FOUNDRY_PROFILE: ci diff --git a/.github/workflows/call.test-ethereum-contracts.yml b/.github/workflows/call.test-ethereum-contracts.yml index 8da108bd63..7b3a5f2627 100644 --- a/.github/workflows/call.test-ethereum-contracts.yml +++ b/.github/workflows/call.test-ethereum-contracts.yml @@ -8,7 +8,7 @@ on: type: boolean jobs: - # Ahhhhhhhhhh, it is silly, but the only way to preparing conditional matrix. + # When this scrip is written, it is the only way to preparing conditional matrix: # Ref: https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional matrix-prep: name: Preparing Conditional Strategy Matrix @@ -19,16 +19,17 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v4 + - name: Check out code into the Go module directory + uses: actions/checkout@v4 - - id: set-matrix - run: | - if [ "${{ inputs.run-coverage-tests }}" == "true" ];then - echo "matrix={\"node-version\": [20]}" >> "$GITHUB_OUTPUT" - else - echo "matrix={\"node-version\": [18, 20]}" >> "$GITHUB_OUTPUT" - fi + - name: Set matrix variable + id: set-matrix + run: | + if [ "${{ inputs.run-coverage-tests }}" == "true" ];then + echo "matrix={\"node-version\": [20]}" >> "$GITHUB_OUTPUT" + else + echo "matrix={\"node-version\": [18, 20]}" >> "$GITHUB_OUTPUT" + fi test-ethereum-contracts: name: Test ethereum-contracts @@ -40,41 +41,55 @@ jobs: strategy: matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }} + env: + DEV_SHELL_NAME: ci-node${{ matrix.node-version }} + defaults: run: - shell: nix develop .#ci-node${{ matrix.node-version }} -c bash -xe {0} + shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0} steps: - uses: actions/checkout@v4 with: submodules: recursive - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Initialize devShell + - name: Set cache key prefix + id: set-cache-key-prefix run: | - node --version - yarn --version - solc --version + node_version=${{ matrix.node-version }} + if [ "${{ inputs.run-coverage-tests }}" == false ]; then + v=ethereum-contracts-test-${node_version}- + else + v=ethereum-contracts-coverage-${node_version}- + fi + echo "cache_key_prefix=$v" >> "$GITHUB_OUTPUT" + shell: bash + + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base + with: + package-name: ethereum-contracts + cache-key-prefix: ${{ steps.set-cache-key-prefix.outputs.cache_key_prefix }} + dev-shell-name: ${{ env.DEV_SHELL_NAME }} - - name: Yarn Install + - name: Install dependencies + if: steps.base.outputs.cache-hit != 'true' run: | yarn install --frozen-lockfile + solc --version + forge --version npx tsc --version npx hardhat --version - name: Lint and build + if: steps.base.outputs.cache-hit != 'true' run: | yarn lint yarn build - ######################################## - ## Test Suite - ######################################## - name: Run test suite - if: inputs.run-coverage-tests == false + if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == false run: | echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV yarn test @@ -84,11 +99,8 @@ jobs: HARDHAT_TEST_JOBS: 4 HARDHAT_RUN_PARALLEL: 1 - ######################################## - ## Coverage Test - ######################################## - name: Run coverage test - if: inputs.run-coverage-tests == true + if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == true run: | echo "FOUNDRY_PROFILE=ci" >> $GITHUB_ENV yarn test-coverage @@ -105,7 +117,7 @@ jobs: HARDHAT_RUN_PARALLEL: 0 - name: Clean up and merge coverage artifacts - if: inputs.run-coverage-tests == true + if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == true run: ./tasks/coverage-cleanup.sh working-directory: ./packages/ethereum-contracts diff --git a/.github/workflows/call.test-hot-fuzz.yml b/.github/workflows/call.test-hot-fuzz.yml index 1b3058696c..9d97f04036 100644 --- a/.github/workflows/call.test-hot-fuzz.yml +++ b/.github/workflows/call.test-hot-fuzz.yml @@ -16,23 +16,26 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + package-name: hot-fuzz + cache-key-prefix: hot-fuzz- + dev-shell-name: ci-hot-fuzz - - name: Initialize devShell + - name: Install dependencies + if: steps.base.outputs.cache-hit != 'true' run: | - set -xe + yarn install + solc --version + forge --version slither --version echidna --version - - name: Run Yarn Install - run: | - yarn install - - name: Run tests - run: | - cd packages/hot-fuzz - ./hot-fuzz contracts/superfluid-tests/SuperHotFuzz.yaml + if: steps.base.outputs.cache-hit != 'true' + run: ./hot-fuzz contracts/superfluid-tests/SuperHotFuzz.yaml + working-directory: packages/hot-fuzz env: - ECHIDNA_TEST_LIMIT: 10000 + ECHIDNA_TEST_LIMIT: 20000 diff --git a/.github/workflows/call.test-local-subgraph.yml b/.github/workflows/call.test-local-subgraph.yml index 51e58e4aad..eea711bd78 100644 --- a/.github/workflows/call.test-local-subgraph.yml +++ b/.github/workflows/call.test-local-subgraph.yml @@ -3,6 +3,10 @@ name: Reusable Workflow | Run Unit and Integration Tests on Local Subgraph on: workflow_call: +env: + # FIXME: subgraph test fails with node20 + DEV_SHELL_NAME: ci-node18 + jobs: subgraph-unit-tests: name: Run subgraph unit tests @@ -13,43 +17,39 @@ jobs: defaults: run: - # FIXME: subgraph test fails with node20 - shell: nix develop .#ci-node18 -c bash -xe {0} + shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0} steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Initialize devShell - run: | - set -ex - node --version - yarn --version + package-name: subgraph + cache-key-prefix: subgraph-unit-tests- + dev-shell-name: ${{ env.DEV_SHELL_NAME }} - - name: "Install dependencies" + - name: Install dependencies + if: steps.base.outputs.cache-hit != 'true' run: | - set -ex yarn install --frozen-lockfile npx tsc --version + npx graph --version - - name: "Build contracts" + - name: Build ethereum contracts + if: steps.base.outputs.cache-hit != 'true' run: | yarn lint yarn build working-directory: ./packages/ethereum-contracts - - name: "Build" - run: npx ts-node scripts/buildNetworkConfig.ts polygon-mainnet - working-directory: ${{ env.subgraph-working-directory }} - - - name: "Run unit tests" + - name: Run unit tests + if: steps.base.outputs.cache-hit != 'true' run: yarn matchstick working-directory: ${{ env.subgraph-working-directory }} - subgraph-end-to-end-integration: + subgraph-integration-tests: name: Run subgraph integration tests runs-on: ubuntu-latest @@ -60,52 +60,64 @@ jobs: defaults: run: - shell: nix develop .#ci-node18 -c bash -xe {0} + shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0} steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + package-name: subgraph + cache-key-prefix: subgraph-integration-tests- + dev-shell-name: ${{ env.DEV_SHELL_NAME }} - - name: "Install dependencies" + - name: Install dependencies + if: steps.base.outputs.cache-hit != 'true' run: yarn install --frozen-lockfile - - name: "Build contracts" + - name: Build contracts + if: steps.base.outputs.cache-hit != 'true' run: yarn build working-directory: ./packages/ethereum-contracts - - name: "Start hardhat node" - run: | - ./tasks/startHardhatNode.sh start + - name: Start hardhat node + if: steps.base.outputs.cache-hit != 'true' + run: ./tasks/startHardhatNode.sh start working-directory: ${{ env.sdk-core-working-directory }} - - name: "Build SDK-Core" + - name: Build SDK core + if: steps.base.outputs.cache-hit != 'true' # build sdk-core because subgraph tests use sdk-core run: yarn build working-directory: ${{ env.sdk-core-working-directory }} - - name: "Deploy Framework and Tokens" + - name: Deploy framework and tokens + if: steps.base.outputs.cache-hit != 'true' run: npx hardhat run dev-scripts/run-deploy-contracts-and-token.js --network localhost working-directory: ./packages/ethereum-contracts - - name: "Prepare files for local testing" + - name: Prepare files for local testing + if: steps.base.outputs.cache-hit != 'true' run: yarn prepare-local working-directory: ${{ env.subgraph-working-directory }} - - name: "Run setup-graph-node" + - name: Run setup-graph-node + if: steps.base.outputs.cache-hit != 'true' run: | chmod +x ./tasks/setup-graph-node.sh ./tasks/setup-graph-node.sh working-directory: ${{ env.subgraph-working-directory }} - - name: "Docker compose" + - name: Docker compose + if: steps.base.outputs.cache-hit != 'true' run: | docker rm subgraph_graph-node_1 || true docker compose up & working-directory: ${{ env.subgraph-working-directory }} - - name: "Run subgraph integration test suite" + - name: Run subgraph integration test suite + if: steps.base.outputs.cache-hit != 'true' run: yarn test --network localhost working-directory: ${{ env.subgraph-working-directory }} diff --git a/.github/workflows/call.test-sdk-core.yml b/.github/workflows/call.test-sdk-core.yml index 46c2131371..b6ffed2ffb 100644 --- a/.github/workflows/call.test-sdk-core.yml +++ b/.github/workflows/call.test-sdk-core.yml @@ -14,78 +14,134 @@ on: type: boolean jobs: + # When this scrip is written, it is the only way to preparing conditional matrix: + # Ref: https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional + matrix-prep: + name: Preparing Conditional Strategy Matrix + + runs-on: ubuntu-latest + + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + + steps: + - name: Set matrix variable + id: set-matrix + run: | + if [ "${{ inputs.run-coverage-tests }}" == "true" ];then + echo "matrix={\"node-version\": [18]}" >> "$GITHUB_OUTPUT" + else + # FIXME: subgraph test fails with node20 + echo "matrix={\"node-version\": [18]}" >> "$GITHUB_OUTPUT" + fi + test-sdk-core: name: Test SDK-Core + needs: [matrix-prep] + runs-on: ubuntu-latest + strategy: + matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }} + env: + DEV_SHELL_NAME: ci-node${{ matrix.node-version }} ethereum-contracts-working-directory: ./packages/ethereum-contracts subgraph-working-directory: ./packages/subgraph sdk-core-working-directory: ./packages/sdk-core defaults: run: - # FIXME: subgraph test fails with node20 - shell: nix develop .#ci-node18 -c bash -xe {0} + shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0} steps: - uses: actions/checkout@v4 + with: + submodules: recursive - - uses: cachix/install-nix-action@v19 + - name: Set cache key prefix + id: set-cache-key-prefix + run: | + node_version=${{ matrix.node-version }} + if [ "${{ inputs.run-coverage-tests }}" == false ]; then + v=sdk-core-test-${node_version}- + else + v=sdk-core-coverage-${node_version}- + fi + echo "cache_key_prefix=$v" >> "$GITHUB_OUTPUT" + shell: bash + + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + package-name: sdk-core + cache-key-prefix: ${{ steps.set-cache-key-prefix.outputs.cache_key_prefix }} + dev-shell-name: ${{ env.DEV_SHELL_NAME }} - - name: "Install dependencies" - run: yarn install --frozen-lockfile + - name: Install dependencies + if: steps.base.outputs.cache-hit != 'true' + run: | + yarn install --frozen-lockfile + npx tsc --version + npx hardhat --version - - name: "Build contracts" + - name: Lint and build essentials + if: steps.base.outputs.cache-hit != 'true' run: | yarn lint yarn build working-directory: ${{ env.ethereum-contracts-working-directory }} - - name: "Start hardhat node" + - name: Start hardhat node + if: steps.base.outputs.cache-hit != 'true' run: | ./tasks/startHardhatNode.sh start working-directory: ${{ env.sdk-core-working-directory }} - - name: "Build SDK-Core" + - name: Build SDK Core + if: steps.base.outputs.cache-hit != 'true' # build sdk-core because of auto linking to dependency run: | yarn lint yarn build working-directory: ${{ env.sdk-core-working-directory }} - - name: "Deploy Framework and Tokens" + - name: Deploy Framework and Tokens + if: steps.base.outputs.cache-hit != 'true' run: npx hardhat run dev-scripts/run-deploy-contracts-and-token.js --network localhost working-directory: ${{ env.ethereum-contracts-working-directory }} - - name: "Prepare files for local testing" + - name: Prepare files for local testing + if: steps.base.outputs.cache-hit != 'true' run: yarn prepare-local working-directory: ${{ env.subgraph-working-directory }} - - name: "Run setup-graph-node" + - name: Run setup-graph-node + if: steps.base.outputs.cache-hit != 'true' run: | chmod +x ./tasks/setup-graph-node.sh ./tasks/setup-graph-node.sh working-directory: ${{ env.subgraph-working-directory }} - - name: "Docker compose" + - name: Docker compose + if: steps.base.outputs.cache-hit != 'true' run: | docker rm subgraph_graph-node_1 || true docker compose up & working-directory: ${{ env.subgraph-working-directory }} - - name: "Build and deploy local subgraph" + - name: Build and deploy local subgraph + if: steps.base.outputs.cache-hit != 'true' run: | yarn build-and-deploy-local # artificial slow down to give the subgraph time to sync sleep 30 working-directory: ${{ env.subgraph-working-directory }} - - name: "Run test suite" - if: inputs.run-coverage-tests == false + - name: Run test suite + if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == false run: | yarn get-graphql-schema:${{ inputs.subgraph-release }} ./tasks/setupTestEnvironment.sh @@ -95,8 +151,8 @@ jobs: SUBGRAPH_RELEASE_TAG: ${{ inputs.subgraph-release }} SUBGRAPH_ENDPOINT: ${{ inputs.subgraph-endpoint }} - - name: "Run coverage test" - if: inputs.run-coverage-tests == true + - name: Run coverage test + if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == true run: | yarn workspace @superfluid-finance/sdk-core test-coverage working-directory: ${{ env.sdk-core-working-directory }} @@ -104,7 +160,7 @@ jobs: SUBGRAPH_RELEASE_TAG: ${{ inputs.subgraph-release }} SUBGRAPH_ENDPOINT: ${{ inputs.subgraph-endpoint }} - - name: "Create coverage artifact" + - name: Create coverage artifact if: inputs.run-coverage-tests == true uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/call.test-solidity-semantic-money.yml b/.github/workflows/call.test-solidity-semantic-money.yml index 5a46c4aff4..cceec6a41d 100644 --- a/.github/workflows/call.test-solidity-semantic-money.yml +++ b/.github/workflows/call.test-solidity-semantic-money.yml @@ -15,22 +15,28 @@ jobs: steps: - uses: actions/checkout@v4 + with: + submodules: recursive - - uses: cachix/install-nix-action@v19 + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + package-name: solidity-semantic-money + cache-key-prefix: solidity-semantic-money- + dev-shell-name: ci-default - - name: Initialize Nix DevShell + - name: Install dependencies + if: steps.base.outputs.cache-hit != 'true' run: | + yarn install --frozen-lockfile + solc --version forge --version - - name: Initialize Node Modules - run: | - yarn install - - - name: Build & Test + - name: Build and test + if: steps.base.outputs.cache-hit != 'true' run: | - cd packages/solidity-semantic-money make build-src test-all + working-directory: packages/solidity-semantic-money env: FOUNDRY_FUZZ_RUNS: 4200 # yea, baby diff --git a/.github/workflows/call.test-spec-haskell.yml b/.github/workflows/call.test-spec-haskell.yml index b4a89792b9..907ddd3676 100644 --- a/.github/workflows/call.test-spec-haskell.yml +++ b/.github/workflows/call.test-spec-haskell.yml @@ -12,49 +12,48 @@ jobs: strategy: matrix: include: - #- compiler-name: ghc-9.2 - # dev-shell-type: ci-spec-ghc92 - compiler-name: ghc-9.4 - dev-shell-type: ci-spec-ghc94 + dev-shell-name: ci-spec-ghc94 fail-fast: false defaults: run: - shell: nix develop .#${{ matrix.dev-shell-type }} -c bash -xe {0} + shell: nix develop .#${{ matrix.dev-shell-name }} -c bash -xe {0} steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 + - name: Setup workflow base + id: base + uses: ./.github/actions/setup-workflow-base with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Initialize devShell - run: | - set -xe - cabal --version - ghc --version + package-name: spec-haskell + cache-key-prefix: spec-haskell-${{ matrix.compiler-name }}- + dev-shell-name: ${{ matrix.dev-shell-name }} - name: Run cabal update + if: steps.base.outputs.cache-hit != 'true' run: | cabal v2-update + cabal --version + ghc --version - name: Run lint - run: | - cd packages/spec-haskell - make lint + if: steps.base.outputs.cache-hit != 'true' + run: make lint + working-directory: packages/spec-haskell - name: Run build - run: | - cd packages/spec-haskell - make build + if: steps.base.outputs.cache-hit != 'true' + run: make build + working-directory: packages/spec-haskell - name: Run tests - run: | - cd packages/spec-haskell - make test + if: steps.base.outputs.cache-hit != 'true' + run: make test + working-directory: packages/spec-haskell - name: Make haddock docs - run: | - cd packages/spec-haskell - make docs-haddock + if: steps.base.outputs.cache-hit != 'true' + run: make docs-haddock + working-directory: packages/spec-haskell diff --git a/.github/workflows/call.test-subgraph-on-previous-sdk-core-versions.yml b/.github/workflows/call.test-subgraph-on-previous-sdk-core-versions.yml index de04046cd1..e13da59427 100644 --- a/.github/workflows/call.test-subgraph-on-previous-sdk-core-versions.yml +++ b/.github/workflows/call.test-subgraph-on-previous-sdk-core-versions.yml @@ -35,9 +35,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: "Install dependencies" run: yarn install --frozen-lockfile diff --git a/.github/workflows/cd.feature.create-pr-artifact.yml b/.github/workflows/cd.feature.create-pr-artifact.yml index a536169efc..0104786319 100644 --- a/.github/workflows/cd.feature.create-pr-artifact.yml +++ b/.github/workflows/cd.feature.create-pr-artifact.yml @@ -19,9 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Show context env: diff --git a/.github/workflows/ci.canary.yml b/.github/workflows/ci.canary.yml index 01cb9d826f..0826f8150a 100644 --- a/.github/workflows/ci.canary.yml +++ b/.github/workflows/ci.canary.yml @@ -4,12 +4,13 @@ on: push: branches: ["dev"] paths: + - ".github/workflows/ci.canary.yml" + - ".github/workflows/call.*.yml" - "package.json" + - "yarn.lock" - "packages/**" - # - "**.md" commented-out because README updates should go to the packages - - ".github/workflows/ci.canary.yml" - "codecov.yml" - - ".github/workflows/call.*.yml" + # - "**.md" are commented out because docs updates should go into the packages jobs: check: @@ -23,30 +24,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Create build set - run: tasks/create-build-set.sh ${{ github.sha }} dev origin - - essential-build-and-test: - name: Build and test essential packages of dev branch - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18, 20] - - defaults: - run: - shell: nix develop .#ci-node${{ matrix.node-version }} -c bash -xe {0} - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive + - uses: DeterminateSystems/nix-installer-action@v13 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Initialize nix dev shell + run: | + node --version + yarn --version + shellcheck --version + actionlint --version - name: Show contexts env: @@ -60,33 +45,71 @@ jobs: echo github.head_ref: "$HEAD_REF" echo github.base_ref: ${{ github.base_ref }} - - name: Install, lint, build, and test + - name: Run global lint run: | - yarn install --frozen-lockfile - yarn lint - yarn build - yarn test - env: - POLYGON_MAINNET_PROVIDER_URL: ${{ secrets.POLYGON_MAINNET_PROVIDER_URL }} - SUBGRAPH_RELEASE_TAG: dev - FOUNDRY_PROFILE: ci + 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) - - test-subgraph: - uses: ./.github/workflows/call.test-local-subgraph.yml - name: Build and Test Subgraph (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: @@ -101,32 +124,6 @@ jobs: secrets: THE_GRAPH_ACCESS_TOKEN: ${{ secrets.THE_GRAPH_ACCESS_TOKEN }} - test-solidity-semantic-money: - name: Build and Test Solidity Semantic Money (Canary Branch) - uses: ./.github/workflows/call.test-solidity-semantic-money.yml - - test-spec-haskell: - uses: ./.github/workflows/call.test-spec-haskell.yml - name: Build and Test Spec Haskell (Canary Branch) - - test-automation-contracts: - uses: ./.github/workflows/call.test-automation-contracts.yml - name: Build and Test Automation Contracts (Canary Branch) - - coverage-ethereum-contracts: - name: Coverage test ethereum-contracts (Canary Branch) - uses: ./.github/workflows/call.test-ethereum-contracts.yml - with: - run-coverage-tests: true - - coverage-sdk-core: - uses: ./.github/workflows/call.test-sdk-core.yml - name: Build and Test SDK-Core Coverage (Canary Branch) - with: - subgraph-release: local - subgraph-endpoint: http://localhost:8000/subgraphs/name/superfluid-test - run-coverage-tests: true - upload-coverage-reports: name: Upload Coverage Reports (Feature Branch) uses: ./.github/workflows/call.upload-coverage-reports.yml @@ -139,13 +136,14 @@ jobs: 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: [ essential-build-and-test - , test-spec-haskell + + 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 - , coverage-ethereum-contracts - , coverage-sdk-core + , test-automation-contracts ] steps: - name: Test Results @@ -161,12 +159,15 @@ jobs: echo "Passed." fi } - check_result essential-build-and-test ${{ needs.essential-build-and-test.result }} 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 ethereum-contracts-coverage ${{ needs.coverage-ethereum-contracts.result }} - check_result sdk-core-coverage ${{ needs.coverage-sdk-core.result }} + check_result automation-contracts ${{ needs.test-automation-contracts.result }} publish-npm-packages: name: Publish canary packages to registries @@ -184,9 +185,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Install dependencies run: yarn install --frozen-lockfile @@ -233,9 +232,7 @@ jobs: repository: superfluid-finance/build-scripts path: build-scripts - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Install dependencies run: yarn install --frozen-lockfile @@ -293,9 +290,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Build run: | diff --git a/.github/workflows/ci.feature.yml b/.github/workflows/ci.feature.yml index d08dca1ef8..01647af667 100644 --- a/.github/workflows/ci.feature.yml +++ b/.github/workflows/ci.feature.yml @@ -38,13 +38,12 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - - name: Initialize devShell + - name: Initialize nix dev shell run: | node --version + yarn --version shellcheck --version actionlint --version @@ -60,12 +59,26 @@ jobs: echo github.head_ref: "$HEAD_REF" echo github.base_ref: ${{ github.base_ref }} - - name: Run pre-commit check - run: npm run pre-commit + - 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: + name: Test Spec Haskell (Feature Branch) + uses: ./.github/workflows/call.test-spec-haskell.yml + needs: [check] + if: needs.check.outputs.build_spec_haskell + + test-solidity-semantic-money: + name: Test Solidity Semantic Money Library (Feature Branch) + uses: ./.github/workflows/call.test-solidity-semantic-money.yml + needs: [ check ] + if: needs.check.outputs.build_solidity_semantic_money + test-ethereum-contracts: name: Test ethereum-contracts (Feature Branch) uses: ./.github/workflows/call.test-ethereum-contracts.yml @@ -88,26 +101,6 @@ jobs: needs: [ check ] if: needs.check.outputs.build_hot_fuzz - test-solidity-semantic-money: - name: Test Solidity Semantic Money Library (Feature Branch) - uses: ./.github/workflows/call.test-solidity-semantic-money.yml - needs: [ check ] - if: needs.check.outputs.build_solidity_semantic_money - - #test automations: - test-automation-contracts: - name: Test Automation Contracts (Feature Branch) - uses: ./.github/workflows/call.test-automation-contracts.yml - needs: [ check ] - if: needs.check.outputs.build_automation_contracts - - # subgraph integration test - test-subgraph: - name: Test Subgraph (Feature Branch) - uses: ./.github/workflows/call.test-local-subgraph.yml - needs: [check] - if: needs.check.outputs.build_subgraph - # sdk-core integration test + local subgraph w/ local sdk-core test-sdk-core: name: Test sdk-core (Feature Branch) @@ -129,11 +122,17 @@ jobs: subgraph-endpoint: http://localhost:8000/subgraphs/name/superfluid-test run-coverage-tests: true - test-spec-haskell: - name: Test Spec Haskell (Feature Branch) - uses: ./.github/workflows/call.test-spec-haskell.yml + test-subgraph: + name: Test Subgraph (Feature Branch) + uses: ./.github/workflows/call.test-local-subgraph.yml needs: [check] - if: needs.check.outputs.build_spec_haskell + if: needs.check.outputs.build_subgraph + + test-automation-contracts: + name: Test Automation Contracts (Feature Branch) + uses: ./.github/workflows/call.test-automation-contracts.yml + needs: [check] + if: needs.check.outputs.build_automation_contracts upload-coverage-reports: name: Upload Coverage Reports (Feature Branch) @@ -170,18 +169,19 @@ jobs: local package_name="$1" local result="$2" if [ "$result" == "skipped" ];then - echo "Skipped $package_name package." + echo "Skipped job: $package_name." else - echo "Checking if $package_name package test passes..." + echo "Checking if the job \"$package_name\" 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 ethereum-contracts ${{ needs.test-ethereum-contracts.result }} - check_result ethereum-contracts-coverage ${{ needs.coverage-ethereum-contracts.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 sdk-core ${{ needs.test-sdk-core.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 }} diff --git a/.github/workflows/handler.deploy-to-mainnet.yml b/.github/workflows/handler.deploy-to-mainnet.yml index 484ac44dbc..165fde5fd3 100644 --- a/.github/workflows/handler.deploy-to-mainnet.yml +++ b/.github/workflows/handler.deploy-to-mainnet.yml @@ -38,9 +38,7 @@ jobs: repository: superfluid-finance/build-scripts path: build-scripts - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Build run: | diff --git a/.github/workflows/handler.deploy-to-testnets.yml b/.github/workflows/handler.deploy-to-testnets.yml index b6ec062b54..5586897a6d 100644 --- a/.github/workflows/handler.deploy-to-testnets.yml +++ b/.github/workflows/handler.deploy-to-testnets.yml @@ -43,7 +43,7 @@ jobs: if: ${{ github.event.inputs.only_network != '' && github.event.inputs.only_network != matrix.network }} run: echo "DO_SKIP=1" >> "$GITHUB_ENV" - - uses: cachix/install-nix-action@v19 + - uses: cachix/install-nix-action@v27 if: env.DO_SKIP != 1 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/handler.list-super-token.yml b/.github/workflows/handler.list-super-token.yml index 67e02909a6..5cbe04f8f8 100644 --- a/.github/workflows/handler.list-super-token.yml +++ b/.github/workflows/handler.list-super-token.yml @@ -40,9 +40,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Build run: | diff --git a/.github/workflows/handler.publish-release-packages.yml b/.github/workflows/handler.publish-release-packages.yml index 0fcb873870..1bf9aa1c9e 100644 --- a/.github/workflows/handler.publish-release-packages.yml +++ b/.github/workflows/handler.publish-release-packages.yml @@ -24,9 +24,7 @@ jobs: repository: superfluid-finance/build-scripts path: build-scripts - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Parse Tag env: diff --git a/.github/workflows/handler.run-ethereum-contracts-script.yml b/.github/workflows/handler.run-ethereum-contracts-script.yml index 0e994beb82..6b0309606a 100644 --- a/.github/workflows/handler.run-ethereum-contracts-script.yml +++ b/.github/workflows/handler.run-ethereum-contracts-script.yml @@ -40,9 +40,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v19 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: DeterminateSystems/nix-installer-action@v13 - name: Build run: | diff --git a/.github/workflows/handler.verify-contracts.yml b/.github/workflows/handler.verify-contracts.yml index 34b4ef08c1..5f63de52ca 100644 --- a/.github/workflows/handler.verify-contracts.yml +++ b/.github/workflows/handler.verify-contracts.yml @@ -37,7 +37,7 @@ jobs: if: ${{ github.event.inputs.only_network != '' && github.event.inputs.only_network != matrix.network }} run: echo "DO_SKIP=1" >> "$GITHUB_ENV" - - uses: cachix/install-nix-action@v19 + - uses: cachix/install-nix-action@v27 if: env.DO_SKIP != 1 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.husky/pre-commit b/.husky/pre-commit index 025779ed2b..4a4468a912 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,17 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -yarn pre-commit +# always lint these +npm run lint:shellcheck +npm run lint:actionlint + +# only lint the workspace if there is staged files +for i in $(jq -r '.workspaces.packages | .[]' package.json); do + if [ -n "$(git diff --name-only HEAD -- "$i")" ]; then ( + echo "= Linting workspace $i" + cd "$i" || exit 3 + npm run lint + ) else { + echo "= Skipping workspace $i: no changed files." + } fi +done diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..846b1f7d48 --- /dev/null +++ b/default.nix @@ -0,0 +1,12 @@ +{ + halfBoardModule = { + includedFiles = [ + # development tooling defined in nix + ./flake.nix + ./flake.lock + # managing the npm dependencies with yarna + ./package.json + ./yarn.lock + ]; + }; +} diff --git a/flake.lock b/flake.lock index fb9e7b1b8b..6c8994fd15 100644 --- a/flake.lock +++ b/flake.lock @@ -42,6 +42,30 @@ "type": "github" } }, + "mk-cache-key": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718047354, + "narHash": "sha256-WGlodS+Ju1rH5CNuDeNDuRMEXAk4A3IZIimIGNMdoxk=", + "owner": "hellwolf", + "repo": "mk-cache-key.nix", + "rev": "82f25a577f25fcb9eed94b3a04330ccf4a102cba", + "type": "github" + }, + "original": { + "owner": "hellwolf", + "ref": "master", + "repo": "mk-cache-key.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1723019560, @@ -62,6 +86,7 @@ "inputs": { "flake-utils": "flake-utils", "foundry": "foundry", + "mk-cache-key": "mk-cache-key", "nixpkgs": "nixpkgs", "solc": "solc" } diff --git a/flake.nix b/flake.nix index 8ab6136c02..6cab030f3e 100644 --- a/flake.nix +++ b/flake.nix @@ -14,9 +14,14 @@ inputs.flake-utils.follows = "flake-utils"; inputs.nixpkgs.follows = "nixpkgs"; }; + mk-cache-key = { + url = "github:hellwolf/mk-cache-key.nix/master"; + inputs.flake-utils.follows = "flake-utils"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils, foundry, solc } : + outputs = { self, nixpkgs, flake-utils, foundry, solc, mk-cache-key } : flake-utils.lib.eachDefaultSystem (system: let minDevSolcVer = "solc_0_8_11"; # minimum solidity version used for external development @@ -32,12 +37,15 @@ ]; }; + mk-cache-key-pkg = mk-cache-key.packages.${system}.default; + # ghc ecosystem ghc = pkgs.haskell.compiler.${ghcVer94}; ghcPkgs = pkgs.haskell.packages.${ghcVer94}; # common dev inputs commonDevInputs = with pkgs; [ + mk-cache-key-pkg gnumake # for shell script linting shellcheck @@ -140,6 +148,9 @@ }; # CI shells + devShells.mk-cache-key = mkShell { + buildInputs = [ mk-cache-key-pkg ]; + }; devShells.ci-default = mkShell { buildInputs = ciInputs ++ minimumDevInputs; }; diff --git a/package.json b/package.json index 721f98049a..4fa3381846 100644 --- a/package.json +++ b/package.json @@ -10,22 +10,30 @@ "license": "MIT", "scripts": { "postinstall": "npm run git-submodule:init && husky install", - "lint": "run-s lint:*", + "lint": "run-s -l lint:*", "lint:shellcheck": "tasks/shellcheck-all-tasks.sh", - "lint:workspaces": "yarn workspaces run lint", "lint:actionlint": "actionlint .github/workflows/*.yml", + "lint:workspaces": "yarn workspaces run lint", "build": "npm run build-essentials #synonym of build-essentials", - "build-essentials": "set -ex;for i in metadata ethereum-contracts js-sdk sdk-core sdk-redux;do yarn workspace @superfluid-finance/$i build;done", - "build-for-contracts-dev": "set -ex;for i in metadata ethereum-contracts js-sdk;do yarn workspace @superfluid-finance/$i build;done", + "build-essentials": "run-s -l build-essentials:*", + "build-essentials:metadata": "yarn workspace @superfluid-finance/metadata build", + "build-essentials:solidity-semantic-money": "yarn workspace @superfluid-finance/solidity-semantic-money build", + "build-essentials:ethereum-contracts": "yarn workspace @superfluid-finance/ethereum-contracts build", + "build-essentials:js-sdk": "yarn workspace @superfluid-finance/js-sdk build", + "build-essentials:sdk-core": "yarn workspace @superfluid-finance/sdk-core build", + "build-essentials:sdk-redux": "yarn workspace @superfluid-finance/sdk-redux build", + "build-for-contracts-dev": "run-s -l build-for-contracts-dev:*", + "build-for-contracts-dev:metadata": "yarn workspace @superfluid-finance/metadata build", + "build-for-contracts-dev:ethereum-contracts": "yarn workspace @superfluid-finance/ethereum-contracts build", + "build-for-contracts-dev:js-sdk": "yarn workspace @superfluid-finance/js-sdk build", "clean": "rm -rf node_modules; rm -rf packages/*/node_modules; yarn workspace @superfluid-finance/ethereum-contracts clean", "test": "set -ex;for i in ethereum-contracts;do yarn workspace @superfluid-finance/$i test;done", "show-versions": "lerna ls --long", - "pre-commit": "npm run lint:shellcheck && npm run lint:actionlint && yarn workspaces run pre-commit", "git-submodule:init": "git submodule update --init --recursive", "git-submodule:update": "git submodule update --recursive", "git-submodule:sync": "git submodule update --remote --recursive;git submodule sync --recursive", "git-submodule:deinit": "git submodule deinit --all --force", - "check-updates": "run-s check-updates:*", + "check-updates": "run-s -l check-updates:*", "check-updates:root": "ncu --target minor --dep dev", "check-updates:workspaces": "yarn workspaces run check-updates", "shell": "nix develop", diff --git a/packages/automation-contracts/autowrap/foundry.toml b/packages/automation-contracts/autowrap/foundry.toml index bc22bba488..38ee59fb0b 100644 --- a/packages/automation-contracts/autowrap/foundry.toml +++ b/packages/automation-contracts/autowrap/foundry.toml @@ -9,6 +9,7 @@ remappings = [ '@openzeppelin/=node_modules/@openzeppelin/', 'ds-test/=lib/forge-std/lib/ds-test/src/', 'forge-std/=lib/forge-std/src/'] +out = 'packages/automation-contracts/autowrap/out/default' [profile.ci] offline = true diff --git a/packages/automation-contracts/autowrap/package.json b/packages/automation-contracts/autowrap/package.json index ccbb894182..a6e7fa8ba6 100644 --- a/packages/automation-contracts/autowrap/package.json +++ b/packages/automation-contracts/autowrap/package.json @@ -9,8 +9,6 @@ "deploy": "npx hardhat deploy --network", "lint": "run-s lint:*", "lint:sol": "solhint -w 0 contracts/*.sol contracts/*/*.sol && echo '✔ Your .sol files look good.'", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", "check-updates": "ncu --target minor" }, "devDependencies": { diff --git a/packages/automation-contracts/default.nix b/packages/automation-contracts/default.nix new file mode 100644 index 0000000000..dacac2bd26 --- /dev/null +++ b/packages/automation-contracts/default.nix @@ -0,0 +1,24 @@ +{ + halfBoardModule = { + dependencies = [ ../ethereum-contracts ]; + outputs = [ + "autowrap/out" + "scheduler/out" + ]; + includedFiles = [ + # autowrap + ./autowrap/foundry.toml + ./autowrap/package.json + ./autowrap/contracts + ./autowrap/test + ./autowrap/script + ./autowrap/.solhint.json + # scheduler + ./scheduler/foundry.toml + ./scheduler/package.json + ./scheduler/contracts + ./scheduler/test + ./scheduler/.solhint.json + ]; + }; +} diff --git a/packages/automation-contracts/scheduler/foundry.toml b/packages/automation-contracts/scheduler/foundry.toml index 55557575b3..6b3a7ebf3a 100644 --- a/packages/automation-contracts/scheduler/foundry.toml +++ b/packages/automation-contracts/scheduler/foundry.toml @@ -9,6 +9,7 @@ remappings = [ '@openzeppelin/=node_modules/@openzeppelin/', 'ds-test/=lib/forge-std/lib/ds-test/src/', 'forge-std/=lib/forge-std/src/'] +out = 'packages/automation-contracts/scheduler/out/default' [profile.ci] offline = true diff --git a/packages/automation-contracts/scheduler/package.json b/packages/automation-contracts/scheduler/package.json index 72ebc8a154..0445eb3281 100644 --- a/packages/automation-contracts/scheduler/package.json +++ b/packages/automation-contracts/scheduler/package.json @@ -9,8 +9,6 @@ "deploy": "npx hardhat deploy --network", "lint": "run-s lint:*", "lint:sol": "solhint -w 0 contracts/*.sol contracts/*/*.sol && echo '✔ Your .sol files look good.'", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", "check-updates": "ncu --target minor" }, "devDependencies": { diff --git a/packages/ethereum-contracts/default.nix b/packages/ethereum-contracts/default.nix new file mode 100644 index 0000000000..b895da1e83 --- /dev/null +++ b/packages/ethereum-contracts/default.nix @@ -0,0 +1,27 @@ +{ + halfBoardModule = { + dependencies = [ + ../.. + ../solidity-semantic-money + ]; + outputs = [ + "build" + "coverage" + ]; + includedFiles = [ + # source code + ./tasks + ./contracts + ./dev-scripts + ./test + ./testsuites + # configurations + ./package.json + ./truffle-config.js + ./hardhat.config.ts + ./foundry.toml + ./tsconfig.json + ./tsconfig.scripts.json + ]; + }; +} diff --git a/packages/ethereum-contracts/package.json b/packages/ethereum-contracts/package.json index f9f8d6ee64..ac3064057b 100644 --- a/packages/ethereum-contracts/package.json +++ b/packages/ethereum-contracts/package.json @@ -44,7 +44,7 @@ "build:post-contracts": "run-p -l build:post-contracts:*", "build:post-contracts:abi-bundle": "tasks/build-bundled-abi.sh", "build:post-contracts:dev-scripts-typings": "rm -rf dev-scripts/*.d.ts dev-scripts/*.d.ts.map; tsc -p tsconfig.scripts.json", - "build:post-contracts:contracts-size": "forge build --sizes > build/contracts-sizes.txt > /dev/null&", + "build:post-contracts:contracts-size": "forge build --sizes > build/contracts-sizes.txt", "verify-framework": "tasks/etherscan-verify-framework.sh", "testenv:start": "test/testenv-ctl.sh start", "testenv:stop": "test/testenv-ctl.sh stop", @@ -71,8 +71,6 @@ "fix": "run-s fix:*", "fix:eslint": "yarn lint-ts --fix", "lint:check-no-focused-tests": "grep -FR .only test || { echo 'No test is focused.';exit 0; } && { echo '✘ You have focused tests.'; exit 1; }", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", "check-updates": "ncu --target minor --dep prod,dev", "cloc": "tasks/cloc.sh", "docgen": "rm -rf docs/api; hardhat docgen" diff --git a/packages/hot-fuzz/default.nix b/packages/hot-fuzz/default.nix new file mode 100644 index 0000000000..32b97ed9a4 --- /dev/null +++ b/packages/hot-fuzz/default.nix @@ -0,0 +1,17 @@ +{ + halfBoardModule = { + dependencies = [ ../ethereum-contracts]; + outputs = [ + "build" + "crytic-export" + ]; + includedFiles = [ + ./package.json + ./foundry.toml + ./contracts + ./scripts + ./hot-fuzz + ./Makefile + ]; + }; +} diff --git a/packages/hot-fuzz/package.json b/packages/hot-fuzz/package.json index 30237032c8..5251c6af1a 100644 --- a/packages/hot-fuzz/package.json +++ b/packages/hot-fuzz/package.json @@ -6,8 +6,6 @@ "scripts": { "lint": "run-s lint:*", "lint:sol": "solhint -w 0 contracts/*.sol contracts/*/*.sol && echo '✔ Your .sol files look good.'", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", "check-updates": "ncu --target minor" }, "bin": { diff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.json index 76003009a8..b6c6eb67ba 100644 --- a/packages/js-sdk/package.json +++ b/packages/js-sdk/package.json @@ -35,10 +35,7 @@ "stats": "webpack --profile --json > stats.json && webpack-bundle-analyzer ./stats.json", "lint": "run-s lint:*", "lint:js-eslint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'", - "check-no-focused-tests": "grep -FR .only test || { echo '✔ No test is focused.';exit 0; } && { echo '✘ You have focused tests.'; exit 1; }", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", - "pre-commit:check-no-focused-tests": "yarn check-no-focused-tests", + "lint:check-no-focused-tests": "grep -FR .only test || { echo '✔ No test is focused.';exit 0; } && { echo '✘ You have focused tests.'; exit 1; }", "check-updates": "ncu --target minor --dep prod,dev", "cloc": "sh tasks/cloc.sh" }, diff --git a/packages/metadata/package.json b/packages/metadata/package.json index 16e503d600..99bfe4f4bc 100644 --- a/packages/metadata/package.json +++ b/packages/metadata/package.json @@ -17,9 +17,6 @@ "scripts": { "build": "./build.sh && echo '@superfluid-finance/metadata build successfully'", "bump-version-to": "./bump-version-to.sh $@", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", - "pre-commit:check": "./tasks/compare-committed-against-build.sh", "lint": "run-s lint:*", "lint:js-eslint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'", "lint:consistency": "./tasks/compare-committed-against-build.sh", diff --git a/packages/sdk-core/default.nix b/packages/sdk-core/default.nix new file mode 100644 index 0000000000..2a218b68d1 --- /dev/null +++ b/packages/sdk-core/default.nix @@ -0,0 +1,29 @@ +{ + halfBoardModule = { + dependencies = [ + ../.. + ../ethereum-contracts + ]; + outputs = [ + "dist" + "coverage" + ]; + includedFiles = [ + # source code + ./tasks + ./src + ./test + ./previous-versions-testing + ./scripts + # configurations + ./package.json + ./hardhat.config.ts + ./subgraph-codegen.yml + ./tsconfig.json + ./tsconfig.module.json + ./tsconfig.test.json + ./tsconfig.typechain.json + ./typedoc.js + ]; + }; +} diff --git a/packages/sdk-core/package.json b/packages/sdk-core/package.json index 4b1724c92a..cbf1aca57c 100644 --- a/packages/sdk-core/package.json +++ b/packages/sdk-core/package.json @@ -40,7 +40,6 @@ "lint:eslint": "eslint src --ext .ts", "fix": "run-s fix:*", "fix:eslint": "yarn lint:eslint --fix", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s lint:*;else true;fi", "set-default-subgraph-release-tag": "node scripts/setDefaultSubgraphReleaseTag.js", "start-node": "hardhat node", "generate": "run-s generate:*", diff --git a/packages/sdk-redux/package.json b/packages/sdk-redux/package.json index f196714c45..471816f638 100644 --- a/packages/sdk-redux/package.json +++ b/packages/sdk-redux/package.json @@ -14,8 +14,7 @@ "module": "dist/module/index.js", "keywords": [], "scripts": { - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s lint:*;else true;fi", - "build": "rm -rf dist && run-p build:*", + "build": "rm -rf dist && run-p -l build:*", "build:main": "tsc -p tsconfig.json", "build:module": "tsc -p tsconfig.module.json", "lint": "run-s lint:*", diff --git a/packages/solidity-semantic-money/default.nix b/packages/solidity-semantic-money/default.nix new file mode 100644 index 0000000000..a71e97068a --- /dev/null +++ b/packages/solidity-semantic-money/default.nix @@ -0,0 +1,14 @@ +{ + halfBoardModule = { + dependencies = [ ../.. ]; + outputs = [ "out" ]; + includedFiles = [ + ./package.json + ./foundry.toml + ./src + ./test + ./.solhint.json + ./Makefile + ]; + }; +} diff --git a/packages/solidity-semantic-money/package.json b/packages/solidity-semantic-money/package.json index 1bb9f1a54d..d7c2654397 100644 --- a/packages/solidity-semantic-money/package.json +++ b/packages/solidity-semantic-money/package.json @@ -8,11 +8,10 @@ "test": "test" }, "scripts": { + "build": "make build-all", "test": "make test-all", "lint": "run-s lint:*", "lint:sol": "solhint -w 0 `find src test -name *.sol` && echo '✔ Your .sol files look good.'", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", "check-updates": "ncu --target minor" }, "dependencies": { diff --git a/packages/spec-haskell/default.nix b/packages/spec-haskell/default.nix new file mode 100644 index 0000000000..1e78d2a40f --- /dev/null +++ b/packages/spec-haskell/default.nix @@ -0,0 +1,17 @@ +{ + halfBoardModule = { + dependencies = [ ]; + outputs = [ + "dist-test" + "dist-docs" + ]; + includedFiles = [ + ../../flake.nix + ../../flake.lock + ./cabal.project + ./cabal.project.freeze + ./Makefile + ./pkgs + ]; + }; +} diff --git a/packages/subgraph/.gitignore b/packages/subgraph/.gitignore index 1cd9202169..07d42023ea 100644 --- a/packages/subgraph/.gitignore +++ b/packages/subgraph/.gitignore @@ -1,3 +1,4 @@ +/cache/ build/ generated/ abis/ @@ -11,4 +12,4 @@ src/addresses.ts tests/.bin hosted-service-networks.json config/*.json -!config/mock.json \ No newline at end of file +!config/mock.json diff --git a/packages/subgraph/cache/solidity-files-cache.json b/packages/subgraph/cache/solidity-files-cache.json deleted file mode 100644 index cb236ef8bf..0000000000 --- a/packages/subgraph/cache/solidity-files-cache.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "_format": "hh-sol-cache-2", - "files": {} -} diff --git a/packages/subgraph/default.nix b/packages/subgraph/default.nix new file mode 100644 index 0000000000..aa4a2cc1c1 --- /dev/null +++ b/packages/subgraph/default.nix @@ -0,0 +1,23 @@ +{ + halfBoardModule = { + dependencies = [ + ../ethereum-contracts + ../sdk-core + ]; + outputs = [ + "abi" + "generate" + ]; + includedFiles = [ + ./package.json + ./config + ./matchstick.yaml + ./schema.graphql + ./tsconfig.json + ./types + ./src + ./scripts + ./tests + ]; + }; +} diff --git a/packages/subgraph/package.json b/packages/subgraph/package.json index 201715ce97..1e9e37cbbb 100644 --- a/packages/subgraph/package.json +++ b/packages/subgraph/package.json @@ -42,8 +42,6 @@ "watch": "graph deploy superfluid-test --node http://localhost:8020/ --ipfs http://localhost:5001 --watch", "lint": "run-s lint:*", "lint:js-eslint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔ Your .js files look good.'", - "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi", - "pre-commit:lint": "yarn lint", "generate-sf-meta": "./tasks/getSFMeta.sh", "generate-sf-meta-local": "COMMIT_HASH=local CONFIGURATION=local BRANCH=local TAG=local ./tasks/getSFMeta.sh", "check-updates": "ncu --target minor --dep prod,dev", diff --git a/sdk-redux-examples/sdk-redux-react-typecript/package.json b/sdk-redux-examples/sdk-redux-react-typecript/package.json index 75e8dc2f0d..0a2fb27355 100644 --- a/sdk-redux-examples/sdk-redux-react-typecript/package.json +++ b/sdk-redux-examples/sdk-redux-react-typecript/package.json @@ -47,8 +47,7 @@ "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "echo test", - "lint": "echo lint", - "pre-commit": "echo pre-commit" + "lint": "echo lint" }, "eslintConfig": { "extends": "react-app" diff --git a/tasks/create-build-set.sh b/tasks/create-build-set.sh index 4336c1ec94..01a7118c20 100755 --- a/tasks/create-build-set.sh +++ b/tasks/create-build-set.sh @@ -56,66 +56,70 @@ if grep -E "^.github/workflows/call\..*\.yml$" "$CHANGED_FILES" > /dev/null; the console.debug "Call workflows changed." setBuildAll fi + # if root package.json changed, rebuild everything if grep -E "^(flake\.nix|flake\.lock|package\.json|yarn\.lock)$" "$CHANGED_FILES" > /dev/null; then console.debug "Root package.json changed." setBuildAll fi + +# if specified haskell folders and files changed +if grep -E "^packages/spec-haskell/" "$CHANGED_FILES" > /dev/null; then + BUILD_SPEC_HASKELL=1 + console.debug SPEC-HASKELL will be tested. +fi + # if specified solidity-semantic-money folders and files changed -if grep -E "^packages/solidity-semantic-money/(src/|test/|foundry\.toml|Makefile|package\.json)" "$CHANGED_FILES" > /dev/null; then +if grep -E "^packages/solidity-semantic-money/" "$CHANGED_FILES" > /dev/null; then BUILD_SOLIDITY_SEMANTIC_MONEY=1 BUILD_ETHEREUM_CONTRACTS=1 console.debug Solidity semantic money will be tested. fi + # if specified ethereum-contracts folders and files changed -if grep -E "^packages/ethereum-contracts/(contracts/|scripts/|test/|truffle-config\.js|package\.json)" "$CHANGED_FILES" > /dev/null; then +if grep -E "^packages/ethereum-contracts/" "$CHANGED_FILES" > /dev/null; then BUILD_ETHEREUM_CONTRACTS=1 BUILD_SUBGRAPH=1 BUILD_HOT_FUZZ=1 BUILD_AUTOMATION_CONTRACTS=1 console.debug Ethereum contracts, HotFuzz and Subgraph will be tested. fi -# if specified hot-fuzz folders and files changed -if grep -E "^packages/hot-fuzz/(contracts/|scripts/|.+\.js|.+\.yaml|hot-fuzz|package\.json)" "$CHANGED_FILES" > /dev/null; then - BUILD_HOT_FUZZ=1 - console.debug HotFuzz will be tested. -fi + # if specified sdk-core folders and files changed -if grep -E "^packages/sdk-core/(src/|test/|package\.json|tsconfig\.*)" "$CHANGED_FILES" > /dev/null; then +if grep -E "^packages/sdk-core/" "$CHANGED_FILES" > /dev/null; then BUILD_SDK_CORE=1 BUILD_SDK_REDUX=1 BUILD_SUBGRAPH=1 console.debug SDK-CORE, SDK-REDUX and SUBGRAPH will be tested. fi + # if specified sdk-redux folders and files changed -if grep -E "^packages/sdk-redux/(src/|test/|package\.json)" "$CHANGED_FILES" > /dev/null; then +if grep -E "^packages/sdk-redux/" "$CHANGED_FILES" > /dev/null; then BUILD_SDK_REDUX=1 console.debug SDK-REDUX will be tested. fi + +# if specified hot-fuzz folders and files changed +if grep -E "^packages/hot-fuzz/" "$CHANGED_FILES" > /dev/null; then + BUILD_HOT_FUZZ=1 + console.debug HotFuzz will be tested. +fi + # if specified subgraph folders and files changed -if grep -E "^packages/subgraph/(subgraph\.template\.yaml|schema\.graphql|config|scripts|src|tasks|test|hardhat\.config\.ts|package\.json|docker-compose\.yml)" "$CHANGED_FILES" > /dev/null; then +if grep -E "^packages/subgraph/" "$CHANGED_FILES" > /dev/null; then BUILD_SUBGRAPH=1 console.debug Subgraph will be tested. fi -# if specified haskell folders and files changed -if grep -E "^packages/spec-haskell/(packages/|cabal\.project)" "$CHANGED_FILES" > /dev/null; then - BUILD_SPEC_HASKELL=1 - console.debug SPEC-HASKELL will be tested. -fi + # if specified automation-contracts/scheduler folders and files changed -if grep -E "^packages/automation-contracts/scheduler/(contracts/|scripts/|test/|truffle-config\.js|package\.json)" "$CHANGED_FILES" > /dev/null; then - BUILD_AUTOMATION_CONTRACTS=1 - console.debug Automation Contracts will be tested. -fi -# if specified automation-contracts/autowrap folders and files changed -if grep -E "^packages/automation-contracts/autowrap/(contracts/|scripts/|test/|truffle-config\.js|package\.json)" "$CHANGED_FILES" > /dev/null; then +if grep -E "^packages/automation-contracts/" "$CHANGED_FILES" > /dev/null; then BUILD_AUTOMATION_CONTRACTS=1 console.debug Automation Contracts will be tested. fi if [ "$BUILD_ETHEREUM_CONTRACTS" == 1 ] || [ "$BUILD_SDK_CORE" == 1 ] || [ "$BUILD_SDK_REDUX" == 1 ]; then - console.debug "PR packages will be published." PUBLISH_PR_ARTIFACT=1 + console.debug "PR packages will be published." fi console.debug "=== END CREATE BUILD SET" diff --git a/tasks/mk-cache-key.sh b/tasks/mk-cache-key.sh new file mode 100755 index 0000000000..0e4c64fb71 --- /dev/null +++ b/tasks/mk-cache-key.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Synopsis: The wrapper of mk-cache-key.nix taking into accoutn git submodule dependencies. + +oops() { echo "$@" >&2; exit 1; } + +cd "$(dirname "$0")"/.. || oops "cd failed" + +modulePath=$(readlink -f "$1") +[ -d "$modulePath" ] || oops "invalid module: ${modulePath}" + +# create additional build context +{ + # include git submodule status + git submodule status +} > additional-build-context.ignored + +mk-cache-key.nix "$PWD" "$modulePath" ./additional-build-context.ignored --json diff --git a/tasks/show-git-rev.sh b/tasks/show-git-rev.sh new file mode 100755 index 0000000000..b2296ee35c --- /dev/null +++ b/tasks/show-git-rev.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh + +{ + echo -n "$(git rev-parse --short HEAD)" + [ -n "$(git status --porcelain)" ] && echo -n " (dirty)" +} | { + if [ "$1" == forge_ffi_mode ]; then + xxd -p + else + cat + fi +}