Skip to content

Commit

Permalink
ci: Propagate github token to actinos to avoid nix reaching GH rate l…
Browse files Browse the repository at this point in the history
…imit easily

Guard against GH rate limit, wait until limit is reset if limit is
nearly reached.

The GH rate limit can be reached after installing Nix when fetching the nixpkgs channel.
Therefore, propagating the GH token to nix.conf ensures that Nix operations have a higher GH rate limit.

Signed-off-by: Thing-han, Lim <[email protected]>
  • Loading branch information
potsrevennil committed Oct 17, 2024
1 parent 8a13524 commit 77bb0de
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/actions/bench/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ runs:
nix-shell: ${{ inputs.nix-shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
custom_shell: ${{ inputs.custom_shell }}
script: |
ARCH=$(uname -m)
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/cbmc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
custom_shell:
description: The shell to use. Only relevant if use-nix is 'false'
default: "bash"
gh_token:
description: Github access token to use
required: true
runs:
using: composite
steps:
Expand All @@ -25,6 +28,7 @@ runs:
nix-shell: ${{ inputs.nix-shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
custom_shell: ${{ inputs.custom_shell }}
script: |
cat >> $GITHUB_STEP_SUMMARY << EOF
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/functest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
custom_shell:
description: The shell to use. Only relevant if no nix-shell specified
default: "bash"
gh_token:
description: Github access token to use
required: true
cflags:
description: CFLAGS to pass to compilation
default: ""
Expand Down Expand Up @@ -66,6 +69,7 @@ runs:
nix-shell: ${{ inputs.nix-shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
custom_shell: ${{ inputs.custom_shell }}
script: |
# only summary on the first time
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
cross-prefix:
description: Binary prefix for cross compilation
default: ""
gh_token:
description: Github access token to use
required: true
runs:
using: composite
steps:
Expand All @@ -28,6 +31,7 @@ runs:
custom_shell: ${{ inputs.custom_shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
script: |
cat >> $GITHUB_STEP_SUMMARY << EOF
## Setup
Expand Down
12 changes: 12 additions & 0 deletions .github/actions/multi-functest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
nix-verbose:
description: Determine wether to suppress nix log or not
default: 'false'
gh_token:
description: Github access token to use
required: true
cflags:
description: CFLAGS to pass to compilation
default: ""
Expand Down Expand Up @@ -44,6 +47,7 @@ runs:
nix-shell: ${{ inputs.nix-shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
custom_shell: ${{ inputs.custom_shell }}
cflags: ${{ inputs.cflags }}
mode: native
Expand All @@ -57,6 +61,8 @@ runs:
with:
nix-shell: ${{ inputs.nix-shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
custom_shell: ${{ inputs.custom_shell }}
cflags: ${{ inputs.cflags }}
mode: native
Expand All @@ -69,6 +75,9 @@ runs:
uses: ./.github/actions/functest
with:
nix-shell: ${{ inputs.nix-shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
custom_shell: ${{ inputs.custom_shell }}
cflags: ${{ inputs.cflags }}
mode: cross
Expand All @@ -81,6 +90,9 @@ runs:
uses: ./.github/actions/functest
with:
nix-shell: ${{ inputs.nix-shell }}
nix-cache: ${{ inputs.nix-cache }}
nix-verbose: ${{ inputs.nix-verbose }}
gh_token: ${{ inputs.gh_token }}
custom_shell: ${{ inputs.custom_shell }}
cflags: ${{ inputs.cflags }}
mode: cross
Expand Down
8 changes: 7 additions & 1 deletion .github/actions/setup-nix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
description: Determine whether to purge cache with primary key or not
required: false
default: 'true'
gh_token:
description: Github access token to use
required: true

runs:
using: composite
Expand Down Expand Up @@ -55,6 +58,8 @@ runs:
- name: Install Nix
shell: bash
if: ${{ steps.nix-pre-check.outputs.installed == 'false' }}
env:
GH_TOKEN: ${{ inputs.gh_token }}
run: |
echo "::group::Nix installation"
mkdir -p ~/.config/nix
Expand All @@ -78,7 +83,7 @@ runs:
if [[ ! -z $GH_TOKEN ]]; then
mkdir -p ~/.config/nix
echo "access-tokens = github.com=$GH_TOKEN" > ~/.config/nix/nix.conf
echo "access-tokens = github.com=$GH_TOKEN" >> ~/.config/nix/nix.conf
fi
if command -v gh >/dev/null 2>&1; then
Expand Down Expand Up @@ -136,6 +141,7 @@ runs:
purge-prefixes: cache-${{ steps.nix-post-check.outputs.cache_prefix }}
purge-created: 0
purge-primary-key: ${{ inputs.purge_cache == 'true' && 'always' || 'never' }}
token: ${{ inputs.gh_token }}
- name: Set Shell
shell: bash -lo pipefail {0}
run: |
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/setup-shell/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
script:
description: The script to be run in the nix shell
required: false
gh_token:
description: Github access token to use
required: true

runs:
using: composite
Expand All @@ -28,6 +31,7 @@ runs:
if: ${{ inputs.nix-shell != '' }}
with:
devShell: ${{ inputs.nix-shell }}
gh_token: ${{ inputs.gh_token }}
verbose: ${{ inputs.nix-verbose }}
cache: ${{ inputs.nix-cache }}
script: ${{ inputs.script }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ jobs:
- name: native build
uses: ./.github/actions/multi-functest
with:
compile_mode: native
gh_token: ${{ secrets.GITHUB_TOKEN }}
compile_mode: nativ
func: false
nistkat: false
kat: falst
- name: native tests (+debug)
uses: ./.github/actions/multi-functest
with:
gh_token: ${{ secrets.GITHUB_TOKEN }}
compile_mode: native
cflags: "-DMLKEM_DEBUG"
- name: cross tests (opt only)
Expand All @@ -92,6 +94,7 @@ jobs:
with:
nix-shell: ci-cross
nix-cache: true
gh_token: ${{ secrets.GITHUB_TOKEN }}
compile_mode: cross
func: false
nistkat: false
Expand All @@ -107,7 +110,9 @@ jobs:
- uses: ./.github/actions/lint
with:
nix-shell: ci-linter
gh_token: ${{ secrets.GITHUB_TOKEN }}
cross-prefix: "aarch64-unknown-linux-gnu-"

ec2_all:
needs: quickcheck
strategy:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci_ec2_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
nix-shell: ${{ steps.preprocess.outputs.nix-shell }}
nix-cache: ${{ inputs.cbmc || inputs.compile_mode == 'cross' }}
nix-verbose: ${{ inputs.verbose }}
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}
cflags: ${{ inputs.cflags }}
compile_mode: ${{ inputs.compile_mode }}
opt: ${{ inputs.opt }}
Expand All @@ -129,12 +130,14 @@ jobs:
with:
nix-shell: ci-linter
nix-verbose: ${{ inputs.verbose }}
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}
- name: CBMC
if: ${{ inputs.cbmc && (success() || failure()) }}
uses: ./.github/actions/cbmc
with:
nix-shell: ${{ steps.preprocess.outputs.nix-shell }}
nix-verbose: ${{ inputs.verbose }}
gh_token: ${{ secrets.AWS_GITHUB_TOKEN }}
stop-ec2-runner:
name: Stop ${{ inputs.name }} (${{ inputs.ec2_instance_type }})
permissions:
Expand Down

0 comments on commit 77bb0de

Please sign in to comment.