diff --git a/.cargo/config.toml b/.cargo/config.toml index 7065f628e4a..1624617dc1d 100755 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -56,4 +56,8 @@ rustflags = ["-C", "target-feature=+crt-static"] [target.i686-pc-windows-msvc] rustflags = ["-C", "target-feature=+crt-static"] [target.aarch64-pc-windows-msvc] -rustflags = ["-C", "target-feature=+crt-static"] \ No newline at end of file +rustflags = ["-C", "target-feature=+crt-static"] + +# Fix https://github.com/rust-lang/cargo/issues/8688 +[http] +check-revoke = false diff --git a/.github/actions/download-artifact/action.yml b/.github/actions/download-artifact/action.yml index df54721d0f6..7d8512bc56f 100644 --- a/.github/actions/download-artifact/action.yml +++ b/.github/actions/download-artifact/action.yml @@ -3,43 +3,50 @@ name: Download Artifact description: Download file to local or artifact to quickly share files between jobs inputs: + cache-type: + description: "Use github, local or lynx cache" + required: true + type: string + choices: + - github + - local + - lynx name: description: "Artifact name" default: "artifact" path: description: "Destination path" required: true - try-local-cache: - description: "Try use local cache to save artifact" - default: false - required: false - type: boolean - link-when-local: - description: "Link file instead of copy file" - default: false - type: boolean - required: false runs: using: composite steps: - - name: Download artifact + - name: Download artifact from github uses: actions/download-artifact@v4.1.7 - if: ${{ startsWith(runner.name, 'GitHub Actions') || inputs.try-local-cache == 'false' }} + if: ${{ inputs.cache-type == 'github' }} with: name: ${{ inputs.name }} path: ${{ inputs.path }} - - name: Download local - if: ${{ !startsWith(runner.name, 'GitHub Actions') && inputs.try-local-cache == 'true' }} + - name: Download artifact from local + if: ${{ inputs.cache-type == 'local' }} shell: bash run: | set -e save_dir=$HOME/.cache/runner/${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }} # download file - if [ "${{ inputs.link-when-local }}" = "true" ]; then - ln -sf $save_dir/* ${{ inputs.path }} - echo "ln -sf $save_dir/* ${{ inputs.path }}" - else - cp -rf $save_dir/* ${{ inputs.path }} - echo "cp -rf $save_dir/* ${{ inputs.path }}" - fi + ln -sf $save_dir/* ${{ inputs.path }} + echo "ln -sf $save_dir/* ${{ inputs.path }}" + - name: Download artifact from lynx + if: ${{ inputs.cache-type == 'lynx' }} + uses: lynx-infra/cache/restore@main + with: + path: ${{ inputs.path }} + key: rust-artifact-${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }} + restore-keys: | + rust-artifact-${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }} + env: + ACCESS_KEY: ${{ env.TOS_ACCESS_KEY }} + SECRET_KEY: ${{ env.TOS_SECRET_KEY }} + BUCKET_NAME: ${{ env.TOS_BUCKET_NAME }} + REGION: ${{ env.TOS_REGION }} + ENDPOINT: ${{ env.TOS_ENDPOINT }} diff --git a/.github/actions/pnpm-cache/action.yml b/.github/actions/pnpm-cache/action.yml index 147ea9d8428..247db4999dc 100644 --- a/.github/actions/pnpm-cache/action.yml +++ b/.github/actions/pnpm-cache/action.yml @@ -3,6 +3,14 @@ name: pnpm cache description: Install Node.js with pnpm global cache inputs: + type: + description: "Use github or local or lynx cache" + required: true + type: string + choices: + - github + - local + - lynx node-version: default: "20" required: false @@ -46,15 +54,30 @@ runs: echo "STORE_PATH is $(pnpm store path)" echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - name: Restore pnpm cache - id: restore - if: ${{ startsWith(runner.name, 'GitHub Actions') }} - uses: actions/cache/restore@v4 + - name: Restore pnpm cache from Github + id: restore-from-github + if: ${{ inputs.type == 'github' }} + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} + restore-keys: | + node-cache-${{ runner.os }}-pnpm- + + - name: Restore pnpm cache from lynx + if: ${{ inputs.type == 'lynx' }} + uses: lynx-infra/cache@main with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} restore-keys: | node-cache-${{ runner.os }}-pnpm- + env: + ACCESS_KEY: ${{ env.TOS_ACCESS_KEY }} + SECRET_KEY: ${{ env.TOS_SECRET_KEY }} + BUCKET_NAME: ${{ env.TOS_BUCKET_NAME }} + REGION: ${{ env.TOS_REGION }} + ENDPOINT: ${{ env.TOS_ENDPOINT }} - name: Install dependencies shell: bash @@ -67,7 +90,7 @@ runs: - name: Save pnpm cache uses: actions/cache/save@v4 - if: ${{ startsWith(runner.name, 'GitHub Actions') && inputs.save-if == 'true' && steps.restore.outputs.cache-hit != 'true' }} + if: ${{ inputs.type == 'github' && inputs.save-if == 'true' && steps.restore-from-github.outputs.cache-hit != 'true' }} with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} key: node-cache-${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }} diff --git a/.github/actions/upload-artifact/action.yml b/.github/actions/upload-artifact/action.yml index 15b6fb31293..16a0712827c 100644 --- a/.github/actions/upload-artifact/action.yml +++ b/.github/actions/upload-artifact/action.yml @@ -3,22 +3,20 @@ name: Upload Artifact description: Upload file to local or artifact to quickly share files between jobs inputs: + cache-type: + description: "Use github or local or lynx cache" + required: true + type: string + choices: + - github + - local + - lynx name: description: "Artifact name" default: "artifact" path: description: "A file, directory or wildcard pattern that describes what to upload" required: true - try-local-cache: - description: "Try use local cache to save artifact" - default: false - required: false - type: boolean - mv-when-local: - description: "Move file instead of copy file" - default: false - type: boolean - required: false outputs: runner-labels: @@ -30,15 +28,29 @@ runs: steps: - name: Upload artifact uses: actions/upload-artifact@v4 - if: ${{ startsWith(runner.name, 'GitHub Actions') || inputs.try-local-cache == 'false' }} + if: ${{ inputs.cache-type == 'github' }} with: name: ${{ inputs.name }} path: ${{ inputs.path }} if-no-files-found: error overwrite: true + + - name: Upload artifact + uses: lynx-infra/cache/save@main + if: ${{ inputs.cache-type == 'lynx' }} + with: + path: ${{ inputs.path }} + key: rust-artifact-${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }} + env: + ACCESS_KEY: ${{ env.TOS_ACCESS_KEY }} + SECRET_KEY: ${{ env.TOS_SECRET_KEY }} + BUCKET_NAME: ${{ env.TOS_BUCKET_NAME }} + REGION: ${{ env.TOS_REGION }} + ENDPOINT: ${{ env.TOS_ENDPOINT }} + - name: Upload local id: upload-local - if: ${{ !startsWith(runner.name, 'GitHub Actions') && inputs.try-local-cache == 'true' }} + if: ${{ inputs.cache-type == 'local' }} shell: bash run: | set -e @@ -53,13 +65,9 @@ runs: save_dir="$cache_dir/${{ github.repository_id }}-${{ github.sha }}-${{ inputs.name }}" rm -rf $save_dir mkdir $save_dir - if [ "${{ inputs.mv-when-local }}" = "true" ]; then - mv -f ${{ inputs.path }} $save_dir - echo "mv -f ${{ inputs.path }} $save_dir" - else - cp -rf ${{ inputs.path }} $save_dir - echo "cp -rf ${{ inputs.path }} $save_dir" - fi + + mv -f ${{ inputs.path }} $save_dir + echo "mv -f ${{ inputs.path }} $save_dir" # TODO echo machine name as runner labels # echo "runner_labels=\"$(uname -n)\"" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 981d9eef2de..71d66a52769 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,13 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: ${{ github.ref_name != 'main' }} +env: + TOS_ACCESS_KEY: ${{ secrets.TOS_ACCESS_KEY }} + TOS_SECRET_KEY: ${{ secrets.TOS_SECRET_KEY }} + TOS_BUCKET_NAME: ${{ vars.TOS_BUCKET_NAME }} + TOS_REGION: ${{ vars.TOS_REGION }} + TOS_ENDPOINT: ${{ vars.TOS_ENDPOINT }} + jobs: get-runner-labels: name: Get Runner Labels @@ -63,6 +70,8 @@ jobs: target: x86_64-unknown-linux-gnu profile: "debug" runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} skipable: ${{ needs.check-changed.outputs.changed != 'true' }} test-release-linux: @@ -81,6 +90,8 @@ jobs: with: target: ${{ matrix.array.target }} runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} test-windows: name: Test Windows @@ -90,7 +101,12 @@ jobs: target: x86_64-pc-windows-msvc profile: "debug" runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} skipable: ${{ needs.check-changed.outputs.changed != 'true' }} + secrets: + TOS_ACCESS_KEY: ${{ secrets.TOS_ACCESS_KEY }} + TOS_SECRET_KEY: ${{ secrets.TOS_SECRET_KEY }} test-release-windows: name: Test Release Windows @@ -107,6 +123,11 @@ jobs: with: target: ${{ matrix.array.target }} runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} + secrets: + TOS_ACCESS_KEY: ${{ secrets.TOS_ACCESS_KEY }} + TOS_SECRET_KEY: ${{ secrets.TOS_SECRET_KEY }} test-mac: name: Test Mac @@ -117,6 +138,8 @@ jobs: target: x86_64-apple-darwin profile: "debug" runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} skipable: ${{ needs.check-changed.outputs.changed != 'true' }} test-release-mac: @@ -133,6 +156,8 @@ jobs: with: target: ${{ matrix.array.target }} runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} cargo-deny: name: Check license of dependencies @@ -181,6 +206,8 @@ jobs: - name: Pnpm Cache uses: ./.github/actions/pnpm-cache + with: + type: github - name: Lint js if: steps.changes.outputs.src == 'true' @@ -203,6 +230,8 @@ jobs: - name: Pnpm Cache uses: ./.github/actions/pnpm-cache + with: + type: github - name: Run run: | @@ -241,6 +270,7 @@ jobs: uses: ./.github/actions/pnpm-cache with: frozen-lockfile: true + type: github rust_check: name: Rust check @@ -259,6 +289,8 @@ jobs: - name: Pnpm Cache # Required by some tests uses: ./.github/actions/pnpm-cache + with: + type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - name: Run Cargo Check run: cargo check --workspace --all-targets --locked # Not using --release because it uses too much cache, and is also slow. @@ -302,6 +334,8 @@ jobs: - name: Pnpm Cache # Required by some tests uses: ./.github/actions/pnpm-cache + with: + type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - name: Install Rust Toolchain uses: ./.github/actions/rustup @@ -330,6 +364,8 @@ jobs: - name: Pnpm Cache # Required by some tests uses: ./.github/actions/pnpm-cache + with: + type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - name: Install Rust Toolchain uses: ./.github/actions/rustup @@ -359,6 +395,8 @@ jobs: - uses: actions/checkout@v4 - name: Pnpm Cache # Required by some tests uses: ./.github/actions/pnpm-cache + with: + type: github - name: Install Rust Toolchain uses: ./.github/actions/rustup diff --git a/.github/workflows/get-runner-labels.yml b/.github/workflows/get-runner-labels.yml index 1e9b9f5545e..471355b0ab1 100644 --- a/.github/workflows/get-runner-labels.yml +++ b/.github/workflows/get-runner-labels.yml @@ -12,12 +12,30 @@ on: LINUX_RUNNER_LABELS: description: "linux runner labels" value: ${{ jobs.main.outputs.LINUX_RUNNER_LABELS }} + LINUX_RUNNER_TYPE: + description: "linux runner type" + value: ${{ jobs.main.outputs.LINUX_RUNNER_TYPE }} + LINUX_CACHE_TYPE: + description: "cache type used for linux runner" + value: ${{ jobs.main.outputs.LINUX_CACHE_TYPE }} MACOS_RUNNER_LABELS: description: "macos runner labels" value: ${{ jobs.main.outputs.MACOS_RUNNER_LABELS }} + MACOS_RUNNER_TYPE: + description: "macos runner type" + value: ${{ jobs.main.outputs.MACOS_RUNNER_TYPE }} + MACOS_CACHE_TYPE: + description: "cache type used for macos runner" + value: ${{ jobs.main.outputs.MACOS_CACHE_TYPE }} WINDOWS_RUNNER_LABELS: description: "windows runner labels" value: ${{ jobs.main.outputs.WINDOWS_RUNNER_LABELS }} + WINDOWS_RUNNER_TYPE: + description: "windows runner type" + value: ${{ jobs.main.outputs.WINDOWS_RUNNER_TYPE }} + WINDOWS_CACHE_TYPE: + description: "cache type used for windows runner" + value: ${{ jobs.main.outputs.WINDOWS_CACHE_TYPE }} jobs: main: @@ -25,8 +43,16 @@ jobs: runs-on: [self-hosted, Linux, ci] outputs: LINUX_RUNNER_LABELS: ${{ steps.run.outputs.LINUX_RUNNER_LABELS }} + LINUX_RUNNER_TYPE: ${{ steps.run.outputs.LINUX_RUNNER_TYPE }} + LINUX_CACHE_TYPE: ${{ steps.run.outputs.LINUX_CACHE_TYPE }} + MACOS_RUNNER_LABELS: ${{ steps.run.outputs.MACOS_RUNNER_LABELS }} + MACOS_RUNNER_TYPE: ${{ steps.run.outputs.MACOS_RUNNER_TYPE }} + MACOS_CACHE_TYPE: ${{ steps.run.outputs.MACOS_CACHE_TYPE }} + WINDOWS_RUNNER_LABELS: ${{ steps.run.outputs.WINDOWS_RUNNER_LABELS }} + WINDOWS_RUNNER_TYPE: ${{ steps.run.outputs.WINDOWS_RUNNER_TYPE }} + WINDOWS_CACHE_TYPE: ${{ steps.run.outputs.WINDOWS_CACHE_TYPE }} steps: - id: run shell: bash @@ -36,6 +62,7 @@ jobs: MACOS_RUNNER_LABELS='${{ vars.MACOS_RUNNER_LABELS }}'; WINDOWS_RUNNER_LABELS='${{ vars.WINDOWS_RUNNER_LABELS }}'; fi + # set default value if [[ -z "$LINUX_RUNNER_LABELS" ]]; then LINUX_RUNNER_LABELS='"ubuntu-latest"'; @@ -46,7 +73,33 @@ jobs: if [[ -z "$WINDOWS_RUNNER_LABELS" ]]; then WINDOWS_RUNNER_LABELS='"windows-latest"'; fi + + if [[ "$LINUX_RUNNER_LABELS" == rspack-* ]]; then + LINUX_RUNNER_TYPE="hosted" + LINUX_CACHE_TYPE="hosted" + else + LINUX_RUNNER_TYPE="github" + LINUX_CACHE_TYPE="github" + fi + + if [[ "$MACOS_RUNNER_LABELS" == rspack-* ]]; then + MACOS_RUNNER_EPHEMERAL="hosted" + MACOS_CACHE_TYPE="hosted" + else + MACOS_RUNNER_EPHEMERAL="github" + MACOS_CACHE_TYPE="github" + fi + # set output echo "LINUX_RUNNER_LABELS=$LINUX_RUNNER_LABELS" >> "$GITHUB_OUTPUT" + echo "LINUX_RUNNER_TYPE=$LINUX_RUNNER_TYPE" >> "$GITHUB_OUTPUT" + echo "LINUX_CACHE_TYPE=$LINUX_CACHE_TYPE" >> "$GITHUB_OUTPUT" + echo "MACOS_RUNNER_LABELS=$MACOS_RUNNER_LABELS" >> "$GITHUB_OUTPUT" - echo "WINDOWS_RUNNER_LABELS=$WINDOWS_RUNNER_LABELS" >> "$GITHUB_OUTPUT" + echo "MACOS_RUNNER_EPHEMERAL=$MACOS_RUNNER_EPHEMERAL" >> "$GITHUB_OUTPUT" + echo "MACOS_CACHE_TYPE=$MACOS_CACHE_TYPE" >> "$GITHUB_OUTPUT" + + # TODO: test + echo "WINDOWS_RUNNER_LABELS='"rspack-windows-2022-large"'" >> "$GITHUB_OUTPUT" + echo "WINDOWS_RUNNER_TYPE=k8s" >> "$GITHUB_OUTPUT" + echo "WINDOWS_CACHE_TYPE=lynx" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/preview-commit.yml b/.github/workflows/preview-commit.yml index 22800b35873..28e3cc8ae64 100644 --- a/.github/workflows/preview-commit.yml +++ b/.github/workflows/preview-commit.yml @@ -36,26 +36,46 @@ jobs: array: - target: x86_64-unknown-linux-gnu runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-gnu runner: "'ubuntu-latest'" + runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: x86_64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: i686-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: aarch64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} - target: aarch64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + runner-type: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_TYPE }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} uses: ./.github/workflows/reusable-build.yml with: target: ${{ matrix.array.target }} runner: ${{ matrix.array.runner }} + runner-type: ${{ matrix.array.runner-type }} + cache-type: ${{ needs.get-runner-labels.outputs.cache-type }} profile: "release-prod" test: false @@ -70,6 +90,8 @@ jobs: - name: Pnpm Cache uses: ./.github/actions/pnpm-cache + with: + type: github - name: Download artifacts uses: actions/download-artifact@v4.1.7 diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml index 45678e541bb..61cdcdfd214 100644 --- a/.github/workflows/release-canary.yml +++ b/.github/workflows/release-canary.yml @@ -28,28 +28,38 @@ jobs: array: - target: x86_64-unknown-linux-gnu runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-gnu runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: x86_64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: i686-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: aarch64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} - target: aarch64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} uses: ./.github/workflows/reusable-build.yml with: ref: ${{inputs.commit}} target: ${{ matrix.array.target }} runner: ${{ matrix.array.runner }} test: false + cache-type: ${{ matrix.array.cache-type }} release: name: Release Canary @@ -64,6 +74,8 @@ jobs: - name: Pnpm Cache uses: ./.github/actions/pnpm-cache + with: + type: github - name: Download artifacts uses: actions/download-artifact@v4.1.7 diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index efe8efdbfbd..cebd7ffdbc0 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -29,26 +29,36 @@ jobs: array: - target: x86_64-unknown-linux-gnu runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-gnu runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: x86_64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: i686-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: aarch64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} - target: aarch64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} uses: ./.github/workflows/reusable-build.yml with: target: ${{ matrix.array.target }} runner: ${{ matrix.array.runner }} + cache-type: ${{ matrix.array.cache-type }} release: name: Release Nightly @@ -61,6 +71,8 @@ jobs: - name: Pnpm Cache uses: ./.github/actions/pnpm-cache + with: + type: github - name: Download artifacts uses: actions/download-artifact@v4.1.7 diff --git a/.github/workflows/release-pull-request.yml b/.github/workflows/release-pull-request.yml index 1a9221606b6..f67a9f41073 100644 --- a/.github/workflows/release-pull-request.yml +++ b/.github/workflows/release-pull-request.yml @@ -42,6 +42,8 @@ jobs: - name: Pnpm Cache uses: ./.github/actions/pnpm-cache + with: + type: github - name: Create Release Pull Request # https://github.com/rspack-contrib/rspack-action diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63ef8ea9808..5dbc8b9a3ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,27 +44,37 @@ jobs: array: - target: x86_64-unknown-linux-gnu runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-gnu runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: x86_64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: aarch64-unknown-linux-musl runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.LINUX_CACHE_TYPE }} - target: i686-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: aarch64-pc-windows-msvc runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.WINDOWS_CACHE_TYPE }} - target: x86_64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} - target: aarch64-apple-darwin runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + cache-type: ${{ needs.get-runner-labels.outputs.MACOS_CACHE_TYPE }} uses: ./.github/workflows/reusable-build.yml with: target: ${{ matrix.array.target }} runner: ${{ matrix.array.runner }} profile: "release-prod" + cache-type: ${{ matrix.array.cache-type }} release: name: Release @@ -84,6 +94,8 @@ jobs: - name: Pnpm Cache uses: ./.github/actions/pnpm-cache + with: + type: github - name: Download artifacts uses: actions/download-artifact@v4.1.7 diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index fe683a327ce..04f7f75f339 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -42,6 +42,9 @@ on: runner: # Runner labels required: true type: string + runner-type: + required: true + type: string profile: # Rust profile, "debug" or "release" default: "release" required: false @@ -53,6 +56,26 @@ on: ref: # Git reference to checkout required: false type: string + cache-type: + description: "Use github or local or lynx cache" + required: true + type: string + # choices: + # - github + # - local + # - lynx + secrets: + TOS_ACCESS_KEY: + required: false + TOS_SECRET_KEY: + required: false + +env: + TOS_ACCESS_KEY: ${{ secrets.TOS_ACCESS_KEY }} + TOS_SECRET_KEY: ${{ secrets.TOS_SECRET_KEY }} + TOS_BUCKET_NAME: ${{ vars.TOS_BUCKET_NAME }} + TOS_REGION: ${{ vars.TOS_REGION }} + TOS_ENDPOINT: ${{ vars.TOS_ENDPOINT }} jobs: build: @@ -69,10 +92,10 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ inputs.ref }} - clean: ${{ startsWith(runner.name, 'GitHub Actions') }} + clean: ${{ inputs.runner-type == 'github' || inputs.runner-type == 'k8s' }} - name: Clean - if: ${{ !inputs.skipable && !startsWith(runner.name, 'GitHub Actions') }} + if: ${{ !inputs.skipable && inputs.runner-type == 'hosted' }} uses: ./.github/actions/clean with: target: ${{ inputs.target }} @@ -85,6 +108,7 @@ jobs: if: ${{ !inputs.skipable }} uses: ./.github/actions/pnpm-cache with: + type: ${{ inputs.cache-type }} save-if: ${{ github.ref_name == 'main' }} - name: Install Rust Toolchain @@ -106,7 +130,7 @@ jobs: - name: Check local cache id: check_cache - if: ${{ inputs.profile == 'debug' && !startsWith(runner.name, 'GitHub Actions') && !inputs.skipable }} + if: ${{ inputs.profile == 'debug' && !inputs.ephemeral && !inputs.skipable }} shell: bash run: | set -e @@ -170,15 +194,21 @@ jobs: - name: Build i686-pc-windows-msvc if: ${{ inputs.target == 'i686-pc-windows-msvc' && steps.check_cache.outputs.files_exists != 'true' && !inputs.skipable }} - run: RUST_TARGET=${{ inputs.target }} DISABLE_PLUGIN=1 pnpm build:binding:${{ inputs.profile }} + run: | + export all_proxy=$http_proxy # Using all_proxy for updating crates.io index + echo "$all_proxy" && RUST_TARGET=${{ inputs.target }} DISABLE_PLUGIN=1 pnpm build:binding:${{ inputs.profile }} - name: Build x86_64-pc-windows-msvc if: ${{ inputs.target == 'x86_64-pc-windows-msvc' && steps.check_cache.outputs.files_exists != 'true' && !inputs.skipable }} - run: RUST_TARGET=${{ inputs.target }} pnpm build:binding:${{ inputs.profile }} + run: | + export all_proxy=$http_proxy + echo "$all_proxy" && RUST_TARGET=${{ inputs.target }} pnpm build:binding:${{ inputs.profile }} - name: Build aarch64-pc-windows-msvc if: ${{ inputs.target == 'aarch64-pc-windows-msvc' && steps.check_cache.outputs.files_exists != 'true' && !inputs.skipable }} - run: RUST_TARGET=${{ inputs.target }} DISABLE_PLUGIN=1 pnpm build:binding:${{ inputs.profile }} + run: | + export all_proxy=$http_proxy + echo "$all_proxy" && RUST_TARGET=${{ inputs.target }} DISABLE_PLUGIN=1 pnpm build:binding:${{ inputs.profile }} # Mac - name: Build x86_64-apple-darwin @@ -189,7 +219,7 @@ jobs: - name: Build aarch64-apple-darwin if: ${{ inputs.target == 'aarch64-apple-darwin' && steps.check_cache.outputs.files_exists != 'true' && !inputs.skipable }} run: | - if [[ "${{ startsWith(runner.name, 'GitHub Actions') }}" == "true" ]]; then + if [[ "${{ inputs.runner-type }}" == "github" ]]; then # Github runner sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; fi @@ -203,10 +233,9 @@ jobs: uses: ./.github/actions/upload-artifact if: ${{ steps.check_cache.outputs.exists != 'true' && !inputs.skipable }} with: + cache-type: ${{ inputs.cache-type }} name: bindings-${{ inputs.target }} path: crates/node_binding/*.node - try-local-cache: ${{ inputs.profile == 'debug' }} - mv-when-local: true e2e: name: E2E Testing @@ -218,10 +247,10 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ inputs.ref }} - clean: ${{ startsWith(runner.name, 'GitHub Actions') }} + clean: ${{ inputs.runner-type == 'github' || inputs.runner-type == 'k8s' }} - name: Clean - if: ${{ !startsWith(runner.name, 'GitHub Actions') }} + if: ${{ inputs.runner-type == 'hosted' }} uses: ./.github/actions/clean with: target: ${{ inputs.target }} @@ -229,14 +258,14 @@ jobs: - name: Download bindings uses: ./.github/actions/download-artifact with: + cache-type: ${{ inputs.cache-type }} name: bindings-${{ inputs.target }} path: crates/node_binding/ - try-local-cache: ${{ inputs.profile == 'debug' }} - link-when-local: true - name: Setup Pnpm uses: ./.github/actions/pnpm-cache with: + type: ${{ inputs.cache-type }} node-version: 20 - name: Run e2e @@ -270,10 +299,10 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ inputs.ref }} - clean: ${{ startsWith(runner.name, 'GitHub Actions') }} + clean: ${{ inputs.runner-type == 'github' || inputs.runner-type == 'k8s' }} - name: Clean - if: ${{ !inputs.skipable && !startsWith(runner.name, 'GitHub Actions') }} + if: ${{ !inputs.skipable && inputs.runner-type == 'hosted' }} uses: ./.github/actions/clean with: target: ${{ inputs.target }} @@ -282,10 +311,9 @@ jobs: if: ${{ !inputs.skipable }} uses: ./.github/actions/download-artifact with: + cache-type: ${{ inputs.cache-type }} name: bindings-${{ inputs.target }} path: crates/node_binding/ - try-local-cache: ${{ inputs.profile == 'debug' }} - link-when-local: true - name: Show restored binding if: ${{ !inputs.skipable }} @@ -296,6 +324,7 @@ jobs: if: ${{ !inputs.skipable }} uses: ./.github/actions/pnpm-cache with: + type: ${{ inputs.cache-type }} node-version: ${{ matrix.node }} ### x86_64-unknown-linux-gnu