diff --git a/.github/workflows/compile-wasm.yml b/.github/workflows/compile-wasm.yml index 0bad0728ad..9a1d7a372e 100644 --- a/.github/workflows/compile-wasm.yml +++ b/.github/workflows/compile-wasm.yml @@ -2,17 +2,19 @@ name: Compile WASM on: [workflow_call, workflow_dispatch] jobs: - compile-wasm: + wasm: runs-on: buildjet-16vcpu-ubuntu-2204 # buildjet for rust, github standard for everything else steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 # turbo cache, shared between buildjet and github - id: turbo-cache + - id: compiled + uses: actions/cache@v3 # turbo cache, shared between buildjet and github with: path: .turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} + key: ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-compiled restore-keys: | - ${{ runner.os }}-turbo- + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }} - uses: pnpm/action-setup@v2 - uses: buildjet/setup-node@v4 # node cache, distinct between buildjet and github with: diff --git a/.github/workflows/extension-publish.yml b/.github/workflows/extension-publish.yml index 537238fe2c..97dea50f0b 100644 --- a/.github/workflows/extension-publish.yml +++ b/.github/workflows/extension-publish.yml @@ -11,24 +11,34 @@ on: workflow_dispatch: jobs: + compile: + uses: ./.github/workflows/compile-wasm.yml + publish: - name: Publish chrome extension environment: ext-publish runs-on: ubuntu-latest + needs: compile steps: - - name: Checkout sources - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: .turbo + key: ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-publish + restore-keys: | + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-compiled - uses: pnpm/action-setup@v2 + - uses: actions/setup-node@v4 with: - version: 8 + node-version: '21' + cache: 'pnpm' + + - run: pnpm install --frozen-lockfile - - name: Install dependencies - run: pnpm install + - run: pnpm turbo telemetry disable - - name: Build monorepo - run: pnpm build + - run: pnpm turbo download-keys --force --cache-dir=.turbo + - run: pnpm turbo build --cache-dir=.turbo - name: Package up extension run: zip -r dist.zip apps/extension/dist diff --git a/.github/workflows/test-wasm.yml b/.github/workflows/test-wasm.yml deleted file mode 100644 index c9aba56dc3..0000000000 --- a/.github/workflows/test-wasm.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Test WASM -on: [workflow_call, workflow_dispatch] - -jobs: - test-rust: - name: 'test:rust' - runs-on: buildjet-16vcpu-ubuntu-2204 # buildjet for rust, github standard for everything else - steps: - - uses: actions/checkout@v4 - - uses: actions/cache@v3 # turbo cache, shared between buildjet and github - id: turbo-cache - with: - path: .turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-turbo- - - uses: pnpm/action-setup@v2 - - uses: buildjet/setup-node@v4 # node cache, distinct between buildjet and github - with: - node-version: '21' - cache: 'pnpm' - - run: pnpm install --frozen-lockfile # commit your lockfile - - run: pnpm turbo telemetry disable - - - uses: dtolnay/rust-toolchain@stable # rust only on buildjet - with: - targets: wasm32-unknown-unknown - - uses: astriaorg/buildjet-rust-cache@v2.5.1 # buildjet rust cache - - uses: jetli/wasm-pack-action@v0.4.0 # preinstall wasm-pack - with: - version: 'latest' - - uses: browser-actions/setup-firefox@v1 # wasm tests in ffx - - - run: pnpm turbo test:rust --cache-dir=.turbo # test wasm - - - run: cargo tree --invert mio --edges features # debug tree - if: failure() - working-directory: packages/wasm/crate diff --git a/.github/workflows/turbo-ci.yml b/.github/workflows/turbo-ci.yml index cf28df1214..525e29558b 100644 --- a/.github/workflows/turbo-ci.yml +++ b/.github/workflows/turbo-ci.yml @@ -9,29 +9,68 @@ on: [pull_request, workflow_dispatch] # pnpm deps are cached by lockfile hash jobs: - wasm-diff: + check-diff: outputs: - wasm-diff: ${{ steps.diff.outputs.exit_code }} + wasm-diff-main: ${{ steps.run-wasm-diff-main.outcome }} + wasm-diff-prev: ${{ steps.run-wasm-diff-prev.outcome }} name: Diff runs-on: ubuntu-latest - if: github.event_name == 'pull_request' # only run on PRs steps: - uses: actions/checkout@v4 - - id: diff # store diff exit code in output - run: git diff --exit-code main packages/wasm/crate + - run: git fetch origin main:main + - run: git fetch origin ${{ github.head_ref }}:${{ github.head_ref }} + - id: run-wasm-diff-main + run: git diff main --exit-code packages/wasm/crate + continue-on-error: true + - id: run-wasm-diff-prev + run: git diff ${{ github.head_ref }} --exit-code packages/wasm/crate continue-on-error: true turbo-compile: name: Compile - needs: wasm-diff - # only run if wasm crate changed, or dispatch - if: github.workflow_dispatch || needs.wasm-diff.outputs.wasm-diff == '1' + needs: check-diff + # only run if wasm crate changed, rerun was requested, or manually dispatched + if: github.event_name == 'workflow_dispatch' || needs.check-diff.outputs.wasm-diff-main == 'failure'|| needs.check-diff.outputs.wasm-diff-prev == 'failure' || github.run_attempt > 1 uses: ./.github/workflows/compile-wasm.yml - test-rust: - name: test:rust - needs: turbo-compile - uses: ./.github/workflows/test-wasm.yml + turbo-test-rust: + name: 'test:rust' + runs-on: buildjet-16vcpu-ubuntu-2204 # buildjet for rust, github standard for everything else + needs: [turbo-compile, turbo-build] + steps: + - uses: actions/checkout@v4 + - id: compiled # this also compiles, so we can use or write the same cache + uses: actions/cache@v3 # turbo cache, shared between buildjet and github + with: + path: .turbo + key: ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-test:rust + restore-keys: | + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-built + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }} + - uses: pnpm/action-setup@v2 + - uses: buildjet/setup-node@v4 # node cache, distinct between buildjet and github + with: + node-version: '21' + cache: 'pnpm' + - run: pnpm install --frozen-lockfile # commit your lockfile + - run: pnpm turbo telemetry disable + + - uses: dtolnay/rust-toolchain@stable # rust only on buildjet + with: + targets: wasm32-unknown-unknown + - uses: astriaorg/buildjet-rust-cache@v2.5.1 # buildjet rust cache + - uses: jetli/wasm-pack-action@v0.4.0 # preinstall wasm-pack + with: + version: 'latest' + - uses: browser-actions/setup-firefox@v1 # wasm tests in ffx + + - run: pnpm turbo test:rust --cache-dir=.turbo # test wasm + + - run: cargo tree --invert mio --edges features # debug tree + if: failure() + working-directory: packages/wasm/crate turbo-lint: name: Lint @@ -40,13 +79,16 @@ jobs: if: always() # always run even if we skip compile steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 # turbo cache, shared between buildjet and github - id: turbo-cache + - id: lint + uses: actions/cache@v3 # turbo cache, shared between buildjet and github with: path: .turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} + key: ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-lint restore-keys: | - ${{ runner.os }}-turbo- + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-compiled + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }} - uses: pnpm/action-setup@v2 - uses: actions/setup-node@v4 # node cache, distinct between buildjet and github with: @@ -64,13 +106,16 @@ jobs: if: always() # always run even if we skip compile steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 - id: turbo-cache + - id: built + uses: actions/cache@v3 with: path: .turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} + key: ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-built restore-keys: | - ${{ runner.os }}-turbo- + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-compiled + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }} - uses: pnpm/action-setup@v2 - uses: actions/setup-node@v4 with: @@ -83,20 +128,24 @@ jobs: turbo-test: strategy: matrix: - task: ['test', 'test:browser'] # all typescript tests - name: ${{ matrix.task }} + test: ['test', 'test:browser'] # all typescript tests + name: ${{ matrix.test }} runs-on: ubuntu-latest needs: turbo-build if: always() # always run even if we skip compile steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 - id: turbo-cache + - id: tested + uses: actions/cache@v3 with: path: .turbo - key: ${{ runner.os }}-turbo-${{ github.sha }} + key: ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-${{ matrix.test }} restore-keys: | - ${{ runner.os }}-turbo- + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-built + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }}-compiled + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }}-${{ github.sha }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }}-${{ github.ref }} + ${{ runner.os }}-turbo-${{ hashFiles('packages/wasm/cargo/src/**') }} - uses: pnpm/action-setup@v2 - uses: actions/setup-node@v4 with: @@ -104,4 +153,4 @@ jobs: cache: 'pnpm' - run: pnpm install --frozen-lockfile - run: pnpm turbo telemetry disable - - run: pnpm turbo ${{ matrix.task }} --cache-dir=.turbo + - run: pnpm turbo ${{ matrix.test }} --cache-dir=.turbo