mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 15:46:36 +00:00
Optimize binstalk-git-repo-api
Use a dedicated github token in CI Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
5bcc243741
commit
2e80eeef97
2 changed files with 120 additions and 118 deletions
234
.github/workflows/ci.yml
vendored
234
.github/workflows/ci.yml
vendored
|
@ -51,16 +51,17 @@ jobs:
|
||||||
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/actions/just-setup
|
- uses: ./.github/actions/just-setup
|
||||||
env:
|
env:
|
||||||
# just-setup use binstall to install sccache,
|
# just-setup use binstall to install sccache,
|
||||||
# which works better when we provide it with GITHUB_TOKEN.
|
# which works better when we provide it with GITHUB_TOKEN.
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- run: just test
|
- run: just test
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.CI_TEST_GITHUB_TOKEN }}
|
||||||
|
CI_UNIT_TEST_GITHUB_TOKEN: ${{ secrets.CI_UNIT_TEST_GITHUB_TOKEN }}
|
||||||
|
|
||||||
cross-check:
|
cross-check:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -85,22 +86,22 @@ jobs:
|
||||||
env:
|
env:
|
||||||
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Enable cargo-zigbuild
|
- name: Enable cargo-zigbuild
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: echo JUST_USE_CARGO_ZIGBUILD=true >> "$GITHUB_ENV"
|
run: echo JUST_USE_CARGO_ZIGBUILD=true >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- uses: ./.github/actions/just-setup
|
- uses: ./.github/actions/just-setup
|
||||||
with:
|
with:
|
||||||
tools: cargo-hack@0.6.10
|
tools: cargo-hack@0.6.10
|
||||||
env:
|
env:
|
||||||
# just-setup use binstall to install sccache,
|
# just-setup use binstall to install sccache,
|
||||||
# which works better when we provide it with GITHUB_TOKEN.
|
# which works better when we provide it with GITHUB_TOKEN.
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- run: just avoid-dev-deps
|
- run: just avoid-dev-deps
|
||||||
- run: just check
|
- run: just check
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -116,12 +117,12 @@ jobs:
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: ./.github/actions/just-setup
|
- uses: ./.github/actions/just-setup
|
||||||
|
|
||||||
- run: just toolchain rustfmt,clippy
|
- run: just toolchain rustfmt,clippy
|
||||||
- run: just avoid-dev-deps
|
- run: just avoid-dev-deps
|
||||||
- run: just lint
|
- run: just lint
|
||||||
|
|
||||||
pr-info:
|
pr-info:
|
||||||
outputs:
|
outputs:
|
||||||
|
@ -130,12 +131,12 @@ jobs:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- id: meta
|
- id: meta
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
uses: cargo-bins/release-meta@v1
|
uses: cargo-bins/release-meta@v1
|
||||||
with:
|
with:
|
||||||
event-data: ${{ toJSON(github.event) }}
|
event-data: ${{ toJSON(github.event) }}
|
||||||
extract-notes-under: '### Release notes'
|
extract-notes-under: "### Release notes"
|
||||||
|
|
||||||
release-dry-run:
|
release-dry-run:
|
||||||
needs: pr-info
|
needs: pr-info
|
||||||
|
@ -158,42 +159,42 @@ jobs:
|
||||||
env:
|
env:
|
||||||
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
|
CARGO_BUILD_TARGET: x86_64-unknown-linux-musl
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Install ${{ env.CARGO_BUILD_TARGET }} target
|
- name: Install ${{ env.CARGO_BUILD_TARGET }} target
|
||||||
run: |
|
run: |
|
||||||
rustup target add $CARGO_BUILD_TARGET
|
rustup target add $CARGO_BUILD_TARGET
|
||||||
pip3 install -r zigbuild-requirements.txt
|
pip3 install -r zigbuild-requirements.txt
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
cache-all-crates: true
|
cache-all-crates: true
|
||||||
- name: Build detect-targets
|
- name: Build detect-targets
|
||||||
run: |
|
run: |
|
||||||
cargo zigbuild --features cli-logging --target $CARGO_BUILD_TARGET
|
cargo zigbuild --features cli-logging --target $CARGO_BUILD_TARGET
|
||||||
# Set working directory here, otherwise `cargo-zigbuild` would download
|
# Set working directory here, otherwise `cargo-zigbuild` would download
|
||||||
# and build quite a few unused dependencies.
|
# and build quite a few unused dependencies.
|
||||||
working-directory: crates/detect-targets
|
working-directory: crates/detect-targets
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: detect-targets
|
name: detect-targets
|
||||||
path: target/${{ env.CARGO_BUILD_TARGET }}/debug/detect-targets
|
path: target/${{ env.CARGO_BUILD_TARGET }}/debug/detect-targets
|
||||||
|
|
||||||
detect-targets-alpine-test:
|
detect-targets-alpine-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: detect-targets-build
|
needs: detect-targets-build
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: detect-targets
|
name: detect-targets
|
||||||
- run: chmod +x detect-targets
|
- run: chmod +x detect-targets
|
||||||
|
|
||||||
- name: Run test in alpine
|
- name: Run test in alpine
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
--mount src="$PWD/detect-targets",dst=/usr/local/bin/detect-targets,type=bind \
|
--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 \
|
--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"
|
alpine /bin/ash -c "apk update && apk add bash && test.sh x86_64-unknown-linux-musl"
|
||||||
|
|
||||||
detect-targets-ubuntu-test:
|
detect-targets-ubuntu-test:
|
||||||
needs: detect-targets-build
|
needs: detect-targets-build
|
||||||
|
@ -205,15 +206,15 @@ jobs:
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: detect-targets
|
name: detect-targets
|
||||||
- run: chmod +x detect-targets
|
- run: chmod +x detect-targets
|
||||||
|
|
||||||
- name: Run test in ubuntu
|
- name: Run test in ubuntu
|
||||||
run: |
|
run: |
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
[ "$(./detect-targets)" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
[ "$(./detect-targets)" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||||
|
|
||||||
detect-targets-more-glibc-test:
|
detect-targets-more-glibc-test:
|
||||||
needs: detect-targets-build
|
needs: detect-targets-build
|
||||||
|
@ -228,33 +229,33 @@ jobs:
|
||||||
- fedora
|
- fedora
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: detect-targets
|
name: detect-targets
|
||||||
- run: chmod +x detect-targets
|
- run: chmod +x detect-targets
|
||||||
|
|
||||||
- name: Run test
|
- name: Run test
|
||||||
run: |
|
run: |
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
[ "$(docker run --rm \
|
[ "$(docker run --rm \
|
||||||
--mount src="$PWD/detect-targets",dst=/usr/local/bin/detect-targets,type=bind \
|
--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')" ]
|
${{ matrix.container }} detect-targets )" = "$(printf 'x86_64-unknown-linux-gnu\nx86_64-unknown-linux-musl')" ]
|
||||||
|
|
||||||
detect-targets-nix-test:
|
detect-targets-nix-test:
|
||||||
needs: detect-targets-build
|
needs: detect-targets-build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: detect-targets
|
name: detect-targets
|
||||||
- run: chmod +x detect-targets
|
- run: chmod +x detect-targets
|
||||||
|
|
||||||
- name: Run test
|
- name: Run test
|
||||||
run: |
|
run: |
|
||||||
set -exuo pipefail
|
set -exuo pipefail
|
||||||
[ "$(docker run --rm \
|
[ "$(docker run --rm \
|
||||||
--mount src="$PWD/detect-targets",dst=/detect-targets,type=bind \
|
--mount src="$PWD/detect-targets",dst=/detect-targets,type=bind \
|
||||||
nixos/nix /detect-targets )" = x86_64-unknown-linux-musl ]
|
nixos/nix /detect-targets )" = x86_64-unknown-linux-musl ]
|
||||||
|
|
||||||
detect-targets-android-check:
|
detect-targets-android-check:
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -268,40 +269,39 @@ jobs:
|
||||||
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
CARGO_BUILD_TARGET: ${{ matrix.target }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Add ${{ matrix.target }}
|
- name: Add ${{ matrix.target }}
|
||||||
run: rustup target 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
|
|
||||||
|
|
||||||
|
- 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
|
# Dummy job to have a stable name for the "all tests pass" requirement
|
||||||
tests-pass:
|
tests-pass:
|
||||||
name: Tests pass
|
name: Tests pass
|
||||||
needs:
|
needs:
|
||||||
- test
|
- test
|
||||||
- cross-check
|
- cross-check
|
||||||
- lint
|
- lint
|
||||||
- release-dry-run
|
- release-dry-run
|
||||||
- detect-targets-build
|
- detect-targets-build
|
||||||
- detect-targets-alpine-test
|
- detect-targets-alpine-test
|
||||||
- detect-targets-ubuntu-test
|
- detect-targets-ubuntu-test
|
||||||
- detect-targets-more-glibc-test
|
- detect-targets-more-glibc-test
|
||||||
- detect-targets-nix-test
|
- detect-targets-nix-test
|
||||||
- detect-targets-android-check
|
- detect-targets-android-check
|
||||||
if: always() # always run even if dependencies fail
|
if: always() # always run even if dependencies fail
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# fail if ANY dependency has failed or cancelled
|
# fail if ANY dependency has failed or cancelled
|
||||||
- if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
|
- if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')"
|
||||||
run: exit 1
|
run: exit 1
|
||||||
- run: exit 0
|
- run: exit 0
|
||||||
|
|
|
@ -508,7 +508,9 @@ mod test {
|
||||||
|
|
||||||
let mut gh_clients = vec![GhApiClient::new(client.clone(), None)];
|
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").or_else(|_| env::var("GITHUB_TOKEN"))
|
||||||
|
{
|
||||||
gh_clients.push(GhApiClient::new(client, Some(token.into())));
|
gh_clients.push(GhApiClient::new(client, Some(token.into())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue