mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Speedup ci (#1724)
* Optimize binstalk-git-repo-api Use a dedicated github token in CI Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Speedup CI using `cargo-nextest` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix release profile override on Windows Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Optimize unit test in binstalk-registry Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Use `secrets.CI_RELEASE_TEST_GITHUB_TOKEN` for just-setup Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix unit testing in justfile Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add retry on rate limit in unit testing Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Only use `CI_UNIT_TEST_GITHUB_TOKEN` in unit testing Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix `test_get_repo_info`: Retry on rate limit Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix `test_has_release_artifact_and_download_artifacts` Retry on rate limit Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
52f172c713
commit
3aae883467
5 changed files with 356 additions and 308 deletions
240
.github/workflows/ci.yml
vendored
240
.github/workflows/ci.yml
vendored
|
@ -51,16 +51,19 @@ jobs:
|
|||
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/just-setup
|
||||
env:
|
||||
# just-setup use binstall to install sccache,
|
||||
# which works better when we provide it with GITHUB_TOKEN.
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/just-setup
|
||||
env:
|
||||
# just-setup use binstall to install sccache,
|
||||
# which works better when we provide it with GITHUB_TOKEN.
|
||||
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||
with:
|
||||
tools: cargo-nextest
|
||||
|
||||
- run: just test
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
||||
- run: just test
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
||||
CI_UNIT_TEST_GITHUB_TOKEN: ${{ secrets.CI_UNIT_TEST_GITHUB_TOKEN }}
|
||||
|
||||
cross-check:
|
||||
strategy:
|
||||
|
@ -85,22 +88,22 @@ jobs:
|
|||
env:
|
||||
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Enable cargo-zigbuild
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: echo JUST_USE_CARGO_ZIGBUILD=true >> "$GITHUB_ENV"
|
||||
- name: Enable cargo-zigbuild
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: echo JUST_USE_CARGO_ZIGBUILD=true >> "$GITHUB_ENV"
|
||||
|
||||
- uses: ./.github/actions/just-setup
|
||||
with:
|
||||
tools: cargo-hack@0.6.10
|
||||
env:
|
||||
# just-setup use binstall to install sccache,
|
||||
# which works better when we provide it with GITHUB_TOKEN.
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: ./.github/actions/just-setup
|
||||
with:
|
||||
tools: cargo-hack@0.6.10
|
||||
env:
|
||||
# just-setup use binstall to install sccache,
|
||||
# which works better when we provide it with GITHUB_TOKEN.
|
||||
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||
|
||||
- run: just avoid-dev-deps
|
||||
- run: just check
|
||||
- run: just avoid-dev-deps
|
||||
- run: just check
|
||||
|
||||
lint:
|
||||
strategy:
|
||||
|
@ -116,12 +119,16 @@ jobs:
|
|||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/just-setup
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/just-setup
|
||||
env:
|
||||
# just-setup use binstall to install sccache,
|
||||
# which works better when we provide it with GITHUB_TOKEN.
|
||||
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||
|
||||
- run: just toolchain rustfmt,clippy
|
||||
- run: just avoid-dev-deps
|
||||
- run: just lint
|
||||
- run: just toolchain rustfmt,clippy
|
||||
- run: just avoid-dev-deps
|
||||
- run: just lint
|
||||
|
||||
pr-info:
|
||||
outputs:
|
||||
|
@ -130,12 +137,12 @@ jobs:
|
|||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: meta
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: cargo-bins/release-meta@v1
|
||||
with:
|
||||
event-data: ${{ toJSON(github.event) }}
|
||||
extract-notes-under: '### Release notes'
|
||||
- id: meta
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: cargo-bins/release-meta@v1
|
||||
with:
|
||||
event-data: ${{ toJSON(github.event) }}
|
||||
extract-notes-under: "### Release notes"
|
||||
|
||||
release-dry-run:
|
||||
needs: pr-info
|
||||
|
@ -158,42 +165,42 @@ jobs:
|
|||
env:
|
||||
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install ${{ env.CARGO_BUILD_TARGET }} target
|
||||
run: |
|
||||
rustup target add $CARGO_BUILD_TARGET
|
||||
pip3 install -r zigbuild-requirements.txt
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-all-crates: true
|
||||
- name: Build detect-targets
|
||||
run: |
|
||||
cargo zigbuild --features cli-logging --target $CARGO_BUILD_TARGET
|
||||
# Set working directory here, otherwise `cargo-zigbuild` would download
|
||||
# and build quite a few unused dependencies.
|
||||
working-directory: crates/detect-targets
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
path: target/${{ env.CARGO_BUILD_TARGET }}/debug/detect-targets
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install ${{ env.CARGO_BUILD_TARGET }} target
|
||||
run: |
|
||||
rustup target add $CARGO_BUILD_TARGET
|
||||
pip3 install -r zigbuild-requirements.txt
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-all-crates: true
|
||||
- name: Build detect-targets
|
||||
run: |
|
||||
cargo zigbuild --features cli-logging --target $CARGO_BUILD_TARGET
|
||||
# Set working directory here, otherwise `cargo-zigbuild` would download
|
||||
# and build quite a few unused dependencies.
|
||||
working-directory: crates/detect-targets
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
path: target/${{ env.CARGO_BUILD_TARGET }}/debug/detect-targets
|
||||
|
||||
detect-targets-alpine-test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: detect-targets-build
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
|
||||
- name: Run test in alpine
|
||||
run: |
|
||||
docker run --rm \
|
||||
--mount src="$PWD/detect-targets",dst=/usr/local/bin/detect-targets,type=bind \
|
||||
--mount src="$PWD/.github/scripts/test-detect-targets-musl.sh",dst=/usr/local/bin/test.sh,type=bind \
|
||||
alpine /bin/ash -c "apk update && apk add bash && test.sh x86_64-unknown-linux-musl"
|
||||
- name: Run test in alpine
|
||||
run: |
|
||||
docker run --rm \
|
||||
--mount src="$PWD/detect-targets",dst=/usr/local/bin/detect-targets,type=bind \
|
||||
--mount src="$PWD/.github/scripts/test-detect-targets-musl.sh",dst=/usr/local/bin/test.sh,type=bind \
|
||||
alpine /bin/ash -c "apk update && apk add bash && test.sh x86_64-unknown-linux-musl"
|
||||
|
||||
detect-targets-ubuntu-test:
|
||||
needs: detect-targets-build
|
||||
|
@ -205,15 +212,15 @@ jobs:
|
|||
- ubuntu-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
|
||||
- name: Run test in ubuntu
|
||||
run: |
|
||||
set -exuo pipefail
|
||||
[ "$(./detect-targets)" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||
- name: Run test in ubuntu
|
||||
run: |
|
||||
set -exuo pipefail
|
||||
[ "$(./detect-targets)" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||
|
||||
detect-targets-more-glibc-test:
|
||||
needs: detect-targets-build
|
||||
|
@ -228,33 +235,33 @@ jobs:
|
|||
- fedora
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
|
||||
- name: Run test
|
||||
run: |
|
||||
set -exuo pipefail
|
||||
[ "$(docker run --rm \
|
||||
--mount src="$PWD/detect-targets",dst=/usr/local/bin/detect-targets,type=bind \
|
||||
${{ matrix.container }} detect-targets )" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||
- name: Run test
|
||||
run: |
|
||||
set -exuo pipefail
|
||||
[ "$(docker run --rm \
|
||||
--mount src="$PWD/detect-targets",dst=/usr/local/bin/detect-targets,type=bind \
|
||||
${{ matrix.container }} detect-targets )" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||
|
||||
detect-targets-nix-test:
|
||||
needs: detect-targets-build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: detect-targets
|
||||
- run: chmod +x detect-targets
|
||||
|
||||
- name: Run test
|
||||
run: |
|
||||
set -exuo pipefail
|
||||
[ "$(docker run --rm \
|
||||
--mount src="$PWD/detect-targets",dst=/detect-targets,type=bind \
|
||||
nixos/nix /detect-targets )" = x86_64-unknown-linux-musl ]
|
||||
- name: Run test
|
||||
run: |
|
||||
set -exuo pipefail
|
||||
[ "$(docker run --rm \
|
||||
--mount src="$PWD/detect-targets",dst=/detect-targets,type=bind \
|
||||
nixos/nix /detect-targets )" = x86_64-unknown-linux-musl ]
|
||||
|
||||
detect-targets-android-check:
|
||||
strategy:
|
||||
|
@ -268,40 +275,39 @@ jobs:
|
|||
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Add ${{ matrix.target }}
|
||||
run: rustup target add ${{ matrix.target }}
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-all-crates: true
|
||||
- name: Build detect-targets
|
||||
run: |
|
||||
cargo check --target ${{ matrix.target }}
|
||||
# Set working directory here, otherwise `cargo-check` would download
|
||||
# and build quite a few unused dependencies.
|
||||
working-directory: crates/detect-targets
|
||||
- name: Add ${{ matrix.target }}
|
||||
run: rustup target add ${{ matrix.target }}
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-all-crates: true
|
||||
- name: Build detect-targets
|
||||
run: |
|
||||
cargo check --target ${{ matrix.target }}
|
||||
# Set working directory here, otherwise `cargo-check` would download
|
||||
# and build quite a few unused dependencies.
|
||||
working-directory: crates/detect-targets
|
||||
|
||||
# Dummy job to have a stable name for the "all tests pass" requirement
|
||||
tests-pass:
|
||||
name: Tests pass
|
||||
needs:
|
||||
- test
|
||||
- cross-check
|
||||
- lint
|
||||
- release-dry-run
|
||||
- detect-targets-build
|
||||
- detect-targets-alpine-test
|
||||
- detect-targets-ubuntu-test
|
||||
- detect-targets-more-glibc-test
|
||||
- detect-targets-nix-test
|
||||
- detect-targets-android-check
|
||||
- test
|
||||
- cross-check
|
||||
- lint
|
||||
- release-dry-run
|
||||
- detect-targets-build
|
||||
- detect-targets-alpine-test
|
||||
- detect-targets-ubuntu-test
|
||||
- detect-targets-more-glibc-test
|
||||
- detect-targets-nix-test
|
||||
- detect-targets-android-check
|
||||
if: always() # always run even if dependencies fail
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# fail if ANY dependency has failed or cancelled
|
||||
- if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
|
||||
run: exit 1
|
||||
- run: exit 0
|
||||
# fail if ANY dependency has failed or cancelled
|
||||
- if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
|
||||
run: exit 1
|
||||
- run: exit 0
|
||||
|
|
253
.github/workflows/release-packages.yml
vendored
253
.github/workflows/release-packages.yml
vendored
|
@ -27,17 +27,28 @@ jobs:
|
|||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { o: macos-14, t: x86_64-apple-darwin, r: true }
|
||||
- { o: macos-14, t: x86_64h-apple-darwin, }
|
||||
- { o: macos-14, t: aarch64-apple-darwin }
|
||||
- { o: ubuntu-latest, t: x86_64-unknown-linux-gnu, g: 2.17, r: true, c: true }
|
||||
- { o: ubuntu-latest, t: armv7-unknown-linux-gnueabihf, g: 2.17, c: true }
|
||||
- { o: ubuntu-latest, t: aarch64-unknown-linux-gnu, g: 2.17, c: true }
|
||||
- { o: ubuntu-latest, t: x86_64-unknown-linux-musl, r: true, c: true }
|
||||
- { o: ubuntu-latest, t: armv7-unknown-linux-musleabihf, c: true }
|
||||
- { o: ubuntu-latest, t: aarch64-unknown-linux-musl, c: true }
|
||||
- { o: windows-latest, t: x86_64-pc-windows-msvc, r: true }
|
||||
- { o: windows-latest, t: aarch64-pc-windows-msvc }
|
||||
- { o: macos-14, t: x86_64-apple-darwin, r: true }
|
||||
- { o: macos-14, t: x86_64h-apple-darwin }
|
||||
- { o: macos-14, t: aarch64-apple-darwin }
|
||||
- {
|
||||
o: ubuntu-latest,
|
||||
t: x86_64-unknown-linux-gnu,
|
||||
g: 2.17,
|
||||
r: true,
|
||||
c: true,
|
||||
}
|
||||
- {
|
||||
o: ubuntu-latest,
|
||||
t: armv7-unknown-linux-gnueabihf,
|
||||
g: 2.17,
|
||||
c: true,
|
||||
}
|
||||
- { o: ubuntu-latest, t: aarch64-unknown-linux-gnu, g: 2.17, c: true }
|
||||
- { o: ubuntu-latest, t: x86_64-unknown-linux-musl, r: true, c: true }
|
||||
- { o: ubuntu-latest, t: armv7-unknown-linux-musleabihf, c: true }
|
||||
- { o: ubuntu-latest, t: aarch64-unknown-linux-musl, c: true }
|
||||
- { o: windows-latest, t: x86_64-pc-windows-msvc, r: true }
|
||||
- { o: windows-latest, t: aarch64-pc-windows-msvc }
|
||||
|
||||
name: ${{ matrix.t }}
|
||||
runs-on: ${{ matrix.o }}
|
||||
|
@ -52,73 +63,77 @@ jobs:
|
|||
JUST_ENABLE_H3: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Override release profile lto settings
|
||||
if: inputs.CARGO_PROFILE_RELEASE_LTO
|
||||
run: echo "CARGO_PROFILE_RELEASE_LTO=${{ inputs.CARGO_PROFILE_RELEASE_LTO }}" >> "$GITHUB_ENV"
|
||||
- name: Override release profile lto settings
|
||||
if: inputs.CARGO_PROFILE_RELEASE_LTO
|
||||
run: echo "CARGO_PROFILE_RELEASE_LTO=${{ inputs.CARGO_PROFILE_RELEASE_LTO }}" >> "$GITHUB_ENV"
|
||||
shell: bash
|
||||
|
||||
- name: Override release profile codegen-units settings
|
||||
if: inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS
|
||||
run: echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${{ inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS }}" >> "$GITHUB_ENV"
|
||||
- name: Override release profile codegen-units settings
|
||||
if: inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS
|
||||
run: echo "CARGO_PROFILE_RELEASE_CODEGEN_UNITS=${{ inputs.CARGO_PROFILE_RELEASE_CODEGEN_UNITS }}" >> "$GITHUB_ENV"
|
||||
shell: bash
|
||||
|
||||
- uses: ./.github/actions/just-setup
|
||||
with:
|
||||
tools: cargo-auditable,rsign2,rage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: ./.github/actions/just-setup
|
||||
with:
|
||||
tools: cargo-auditable,rsign2,rage
|
||||
env:
|
||||
# just-setup use binstall to install sccache,
|
||||
# which works better when we provide it with GITHUB_TOKEN.
|
||||
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||
|
||||
- run: just toolchain rust-src
|
||||
- run: just toolchain rust-src
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.pub
|
||||
- run: just package
|
||||
- if: runner.os == 'Windows'
|
||||
run: Get-ChildItem packages/
|
||||
- if: runner.os != 'Windows'
|
||||
run: ls -shal packages/
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.pub
|
||||
- run: just package
|
||||
- if: runner.os == 'Windows'
|
||||
run: Get-ChildItem packages/
|
||||
- if: runner.os != 'Windows'
|
||||
run: ls -shal packages/
|
||||
|
||||
- name: Ensure release binary is runnable
|
||||
if: "matrix.r"
|
||||
run: just e2e-tests
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||
- name: Ensure release binary is runnable
|
||||
if: "matrix.r"
|
||||
run: just e2e-tests
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.CI_RELEASE_TEST_GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.key.age
|
||||
- name: Sign package
|
||||
env:
|
||||
AGE_KEY_SECRET: ${{ secrets.AGE_KEY_SECRET }}
|
||||
shell: bash
|
||||
run: .github/scripts/ephemeral-sign.sh packages/cargo-binstall-*
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.key.age
|
||||
- name: Sign package
|
||||
env:
|
||||
AGE_KEY_SECRET: ${{ secrets.AGE_KEY_SECRET }}
|
||||
shell: bash
|
||||
run: .github/scripts/ephemeral-sign.sh packages/cargo-binstall-*
|
||||
|
||||
- if: fromJSON(inputs.publish).is-release == 'true'
|
||||
name: Upload to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
release_name: v${{ fromJSON(inputs.publish).version }}
|
||||
tag: v${{ fromJSON(inputs.publish).version }}
|
||||
body: ${{ fromJSON(inputs.publish).notes }}
|
||||
file: packages/cargo-binstall-*
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
- if: "fromJSON(inputs.publish).is-release != 'true' || runner.os == 'macOS'"
|
||||
name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.t }}
|
||||
path: packages/cargo-binstall-*
|
||||
retention-days: 1
|
||||
- if: fromJSON(inputs.publish).is-release == 'true'
|
||||
name: Upload to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
release_name: v${{ fromJSON(inputs.publish).version }}
|
||||
tag: v${{ fromJSON(inputs.publish).version }}
|
||||
body: ${{ fromJSON(inputs.publish).notes }}
|
||||
file: packages/cargo-binstall-*
|
||||
file_glob: true
|
||||
prerelease: true
|
||||
- if: "fromJSON(inputs.publish).is-release != 'true' || runner.os == 'macOS'"
|
||||
name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.t }}
|
||||
path: packages/cargo-binstall-*
|
||||
retention-days: 1
|
||||
|
||||
- name: Upload timings
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.t }}-cargo-timings
|
||||
path: target/cargo-timings
|
||||
retention-days: 1
|
||||
- name: Upload timings
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.t }}-cargo-timings
|
||||
path: target/cargo-timings
|
||||
retention-days: 1
|
||||
|
||||
lipo:
|
||||
needs: build
|
||||
|
@ -130,58 +145,58 @@ jobs:
|
|||
JUST_FOR_RELEASE: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: just,rsign2,rage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: just,rsign2,rage
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: x86_64h-apple-darwin
|
||||
path: packages/
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: x86_64-apple-darwin
|
||||
path: packages/
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: aarch64-apple-darwin
|
||||
path: packages/
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: x86_64h-apple-darwin
|
||||
path: packages/
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: x86_64-apple-darwin
|
||||
path: packages/
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: aarch64-apple-darwin
|
||||
path: packages/
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.pub
|
||||
- run: ls -shalr packages/
|
||||
- run: just repackage-lipo
|
||||
- run: ls -shal packages/
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.pub
|
||||
- run: ls -shalr packages/
|
||||
- run: just repackage-lipo
|
||||
- run: ls -shal packages/
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.key.age
|
||||
- env:
|
||||
AGE_KEY_SECRET: ${{ secrets.AGE_KEY_SECRET }}
|
||||
shell: bash
|
||||
run: .github/scripts/ephemeral-sign.sh packages/cargo-binstall-universal-*
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: minisign.key.age
|
||||
- env:
|
||||
AGE_KEY_SECRET: ${{ secrets.AGE_KEY_SECRET }}
|
||||
shell: bash
|
||||
run: .github/scripts/ephemeral-sign.sh packages/cargo-binstall-universal-*
|
||||
|
||||
- if: fromJSON(inputs.publish).is-release == 'true'
|
||||
name: Upload to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: v${{ fromJSON(inputs.publish).version }}
|
||||
release_name: v${{ fromJSON(inputs.publish).version }}
|
||||
body: ${{ fromJSON(inputs.publish).notes }}
|
||||
file: packages/cargo-binstall-universal-*
|
||||
file_glob: true
|
||||
overwrite: true
|
||||
prerelease: true
|
||||
- if: fromJSON(inputs.publish).is-release != 'true'
|
||||
name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: universal-apple-darwin
|
||||
path: packages/cargo-binstall-universal-*
|
||||
retention-days: 1
|
||||
- if: fromJSON(inputs.publish).is-release == 'true'
|
||||
name: Upload to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
tag: v${{ fromJSON(inputs.publish).version }}
|
||||
release_name: v${{ fromJSON(inputs.publish).version }}
|
||||
body: ${{ fromJSON(inputs.publish).notes }}
|
||||
file: packages/cargo-binstall-universal-*
|
||||
file_glob: true
|
||||
overwrite: true
|
||||
prerelease: true
|
||||
- if: fromJSON(inputs.publish).is-release != 'true'
|
||||
name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: universal-apple-darwin
|
||||
path: packages/cargo-binstall-universal-*
|
||||
retention-days: 1
|
||||
|
|
|
@ -508,7 +508,7 @@ mod test {
|
|||
|
||||
let mut gh_clients = vec![GhApiClient::new(client.clone(), None)];
|
||||
|
||||
if let Ok(token) = env::var("GITHUB_TOKEN") {
|
||||
if let Ok(token) = env::var("CI_UNIT_TEST_GITHUB_TOKEN") {
|
||||
gh_clients.push(GhApiClient::new(client, Some(token.into())));
|
||||
}
|
||||
|
||||
|
@ -535,40 +535,36 @@ mod test {
|
|||
let mut tests: Vec<(_, _)> = Vec::new();
|
||||
|
||||
for client in create_client() {
|
||||
for repo in PUBLIC_REPOS {
|
||||
let spawn_get_repo_info_task = |repo| {
|
||||
let client = client.clone();
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
match client.get_repo_info(&repo).await {
|
||||
Err(GhApiError::RateLimit { retry_after }) => {
|
||||
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
||||
}
|
||||
res => break res,
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
for repo in PUBLIC_REPOS {
|
||||
tests.push((
|
||||
Some(RepoInfo::new(repo.clone(), false)),
|
||||
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
||||
spawn_get_repo_info_task(repo),
|
||||
));
|
||||
}
|
||||
|
||||
for repo in NON_EXISTENT_REPOS {
|
||||
let client = client.clone();
|
||||
|
||||
tests.push((
|
||||
None,
|
||||
tokio::spawn(async move { client.get_repo_info(&repo).await }),
|
||||
));
|
||||
tests.push((None, spawn_get_repo_info_task(repo)));
|
||||
}
|
||||
|
||||
if client.has_gh_token() {
|
||||
for repo in PRIVATE_REPOS {
|
||||
let client = client.clone();
|
||||
|
||||
tests.push((
|
||||
Some(RepoInfo::new(repo.clone(), true)),
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
match client.get_repo_info(&repo).await {
|
||||
Err(GhApiError::RateLimit { retry_after }) => {
|
||||
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
||||
}
|
||||
res => break res,
|
||||
}
|
||||
}
|
||||
}),
|
||||
spawn_get_repo_info_task(repo),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -606,6 +602,20 @@ mod test {
|
|||
let mut tasks = Vec::new();
|
||||
|
||||
for client in create_client() {
|
||||
async fn has_release_artifact(
|
||||
client: &GhApiClient,
|
||||
artifact: &GhReleaseArtifact,
|
||||
) -> Result<Option<GhReleaseArtifactUrl>, GhApiError> {
|
||||
loop {
|
||||
match client.has_release_artifact(artifact.clone()).await {
|
||||
Err(GhApiError::RateLimit { retry_after }) => {
|
||||
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
||||
}
|
||||
res => break res,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (release, artifacts) in RELEASES {
|
||||
for artifact_name in artifacts {
|
||||
let client = client.clone();
|
||||
|
@ -632,15 +642,10 @@ mod test {
|
|||
.into_bytes(),
|
||||
)
|
||||
});
|
||||
|
||||
let artifact_url = loop {
|
||||
match client.has_release_artifact(artifact.clone()).await {
|
||||
Err(GhApiError::RateLimit { retry_after }) => {
|
||||
sleep(retry_after.unwrap_or(DEFAULT_RETRY_AFTER)).await
|
||||
}
|
||||
res => break res.unwrap().unwrap(),
|
||||
}
|
||||
};
|
||||
let artifact_url = has_release_artifact(&client, &artifact)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
if let Some(browser_download_task) = browser_download_task {
|
||||
let artifact_download_data = loop {
|
||||
|
@ -666,13 +671,15 @@ mod test {
|
|||
let client = client.clone();
|
||||
tasks.push(tokio::spawn(async move {
|
||||
assert_eq!(
|
||||
client
|
||||
.has_release_artifact(GhReleaseArtifact {
|
||||
has_release_artifact(
|
||||
&client,
|
||||
&GhReleaseArtifact {
|
||||
release,
|
||||
artifact_name: "123z".to_compact_string(),
|
||||
})
|
||||
.await
|
||||
.unwrap(),
|
||||
}
|
||||
)
|
||||
.await
|
||||
.unwrap(),
|
||||
None
|
||||
);
|
||||
}));
|
||||
|
@ -683,13 +690,15 @@ mod test {
|
|||
|
||||
tasks.push(tokio::spawn(async move {
|
||||
assert_eq!(
|
||||
client
|
||||
.has_release_artifact(GhReleaseArtifact {
|
||||
has_release_artifact(
|
||||
&client,
|
||||
&GhReleaseArtifact {
|
||||
release,
|
||||
artifact_name: "1234".to_compact_string(),
|
||||
})
|
||||
.await
|
||||
.unwrap(),
|
||||
}
|
||||
)
|
||||
.await
|
||||
.unwrap(),
|
||||
None
|
||||
);
|
||||
}));
|
||||
|
|
|
@ -218,7 +218,7 @@ mod test {
|
|||
|
||||
/// Mark this as an async fn so that you won't accidentally use it in
|
||||
/// sync context.
|
||||
async fn create_client() -> Client {
|
||||
fn create_client() -> Client {
|
||||
Client::new(
|
||||
concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION")),
|
||||
None,
|
||||
|
@ -231,31 +231,40 @@ mod test {
|
|||
|
||||
#[tokio::test]
|
||||
async fn test_crates_io_sparse_registry() {
|
||||
let client = create_client().await;
|
||||
|
||||
let sparse_registry: Registry = Registry::crates_io_sparse_registry();
|
||||
assert!(
|
||||
matches!(sparse_registry, Registry::Sparse(_)),
|
||||
"{:?}",
|
||||
sparse_registry
|
||||
);
|
||||
let client = create_client();
|
||||
|
||||
let crate_name = "cargo-binstall";
|
||||
let version_req = &VersionReq::parse("=1.0.0").unwrap();
|
||||
let manifest_from_sparse = sparse_registry
|
||||
.fetch_crate_matched(client.clone(), crate_name, version_req)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let serialized_manifest_from_sparse_task = tokio::spawn({
|
||||
let client = client.clone();
|
||||
let version_req = version_req.clone();
|
||||
|
||||
async move {
|
||||
let sparse_registry: Registry = Registry::crates_io_sparse_registry();
|
||||
assert!(
|
||||
matches!(sparse_registry, Registry::Sparse(_)),
|
||||
"{:?}",
|
||||
sparse_registry
|
||||
);
|
||||
|
||||
let manifest_from_sparse = sparse_registry
|
||||
.fetch_crate_matched(client, crate_name, &version_req)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
to_string(&manifest_from_sparse).unwrap()
|
||||
}
|
||||
});
|
||||
|
||||
let manifest_from_cratesio_api = fetch_crate_cratesio_api(client, crate_name, version_req)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let serialized_manifest_from_sparse = to_string(&manifest_from_sparse).unwrap();
|
||||
let serialized_manifest_from_cratesio_api = to_string(&manifest_from_cratesio_api).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
serialized_manifest_from_sparse,
|
||||
serialized_manifest_from_sparse_task.await.unwrap(),
|
||||
serialized_manifest_from_cratesio_api
|
||||
);
|
||||
}
|
||||
|
@ -263,34 +272,42 @@ mod test {
|
|||
#[cfg(feature = "git")]
|
||||
#[tokio::test]
|
||||
async fn test_crates_io_git_registry() {
|
||||
let client = create_client().await;
|
||||
|
||||
let git_registry: Registry = "https://github.com/rust-lang/crates.io-index"
|
||||
.parse()
|
||||
.unwrap();
|
||||
assert!(
|
||||
matches!(git_registry, Registry::Git(_)),
|
||||
"{:?}",
|
||||
git_registry
|
||||
);
|
||||
let client = create_client();
|
||||
|
||||
let crate_name = "cargo-binstall";
|
||||
let version_req = &VersionReq::parse("=1.0.0").unwrap();
|
||||
let manifest_from_git = git_registry
|
||||
.fetch_crate_matched(client.clone(), crate_name, version_req)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let serialized_manifest_from_git_task = tokio::spawn({
|
||||
let version_req = version_req.clone();
|
||||
let client = client.clone();
|
||||
|
||||
async move {
|
||||
let git_registry: Registry = "https://github.com/rust-lang/crates.io-index"
|
||||
.parse()
|
||||
.unwrap();
|
||||
assert!(
|
||||
matches!(git_registry, Registry::Git(_)),
|
||||
"{:?}",
|
||||
git_registry
|
||||
);
|
||||
|
||||
let manifest_from_git = git_registry
|
||||
.fetch_crate_matched(client, crate_name, &version_req)
|
||||
.await
|
||||
.unwrap();
|
||||
to_string(&manifest_from_git).unwrap()
|
||||
}
|
||||
});
|
||||
|
||||
let manifest_from_cratesio_api = Registry::default()
|
||||
.fetch_crate_matched(client, crate_name, version_req)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let serialized_manifest_from_git = to_string(&manifest_from_git).unwrap();
|
||||
let serialized_manifest_from_cratesio_api = to_string(&manifest_from_cratesio_api).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
serialized_manifest_from_git,
|
||||
serialized_manifest_from_git_task.await.unwrap(),
|
||||
serialized_manifest_from_cratesio_api
|
||||
);
|
||||
}
|
||||
|
|
3
justfile
3
justfile
|
@ -260,7 +260,8 @@ e2e-test-tls: (e2e-test "tls" "1.2") (e2e-test "tls" "1.3")
|
|||
e2e-tests: e2e-test-live e2e-test-manifest-path e2e-test-git e2e-test-other-repos e2e-test-strategies e2e-test-version-syntax e2e-test-upgrade e2e-test-tls e2e-test-self-upgrade-no-symlink e2e-test-uninstall e2e-test-subcrate e2e-test-no-track e2e-test-registries e2e-test-signing e2e-test-continue-on-failure e2e-test-private-github-repo
|
||||
|
||||
unit-tests: print-env
|
||||
{{cargo-bin}} test {{cargo-build-args}}
|
||||
cargo nextest run {{cargo-build-args}}
|
||||
cargo test --doc {{cargo-build-args}}
|
||||
|
||||
test: unit-tests build e2e-tests
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue