Skip to content

Commit

Permalink
build: enable cloning private repos
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverNChalk committed Nov 25, 2024
1 parent f2b81c9 commit 19293f8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 8 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/actions/checkout/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: checkout
description: "Checks out repo with optional token"
inputs:
token:
description: "Access token for private repos"
required: false

runs:
using: "composite"
steps:
- uses: actions/checkout@v3
if: "${{ inputs.token != null }}"
with:
token: ${{ secrets.CI_READ }}
submodules: recursive
- uses: actions/checkout@v3
if: "${{ inputs.token == null }}"
with:
submodules: recursive
10 changes: 10 additions & 0 deletions .github/workflows/actions/rust-toolchain/action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: rust-toolchain
description: "Sets up a standard rust toolchain"
inputs:
toolchain:
description: "Which rust toolchain to use"
required: false
token:
description: "Access token for private repos"
required: false

runs:
using: "composite"
Expand All @@ -23,3 +27,9 @@ runs:
- uses: Swatinem/[email protected]
with:
shared-key: ${{ steps.get-toolchain.outputs.toolchain }}
- run: git config --global url."https://x-access-token:${{ inputs.token }}@github.com/".insteadOf "https://github.com/"
if: ${{ inputs.token != null }}
shell: bash
- run: git config --global url."https://${{ inputs.token }}@github.com/".insteadOf "[email protected]:"
if: ${{ inputs.token != null }}
shell: bash
27 changes: 19 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,38 @@ jobs:
if: needs.skip-duplicates.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/checkout
with:
submodules: recursive
token: ${{ secrets.CI_READ }}
- uses: ./.github/workflows/actions/rust-toolchain
with:
token: ${{ secrets.CI_READ }}
- run: cargo check --all-features

test:
needs: skip-duplicates
if: needs.skip-duplicates.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/checkout
with:
submodules: recursive
token: ${{ secrets.CI_READ }}
- uses: ./.github/workflows/actions/rust-toolchain
with:
token: ${{ secrets.CI_READ }}
- run: cargo test --all-features

fmt:
needs: skip-duplicates
if: needs.skip-duplicates.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/checkout
with:
submodules: recursive
token: ${{ secrets.CI_READ }}
- uses: ./.github/workflows/actions/rust-toolchain
with:
token: ${{ secrets.CI_READ }}
toolchain: nightly
- run: rustup component add rustfmt
- run: cargo fmt --all --check
Expand All @@ -59,9 +64,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/checkout
with:
submodules: recursive
token: ${{ secrets.CI_READ }}
- uses: ./.github/workflows/actions/rust-toolchain
with:
token: ${{ secrets.CI_READ }}
- run: rustup component add clippy
- run: cargo clippy --all-features -- --deny warnings

Expand All @@ -71,7 +79,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/checkout
with:
submodules: recursive
token: ${{ secrets.CI_READ }}
- uses: ./.github/workflows/actions/rust-toolchain
with:
token: ${{ secrets.CI_READ }}
- run: cargo doc --all-features --no-deps

0 comments on commit 19293f8

Please sign in to comment.