Skip to content

Commit 333c193

Browse files
authored
ci: debug workflow, rate limit fixes, cleanup (#168)
Update the debug workflow to echo a message with some basic info on how to use tmate. Also rename the job to `debug`, put the timeout at the job level, and set a Homebrew GitHub token to help with rate limiting (as described below). The changes in the second commit fix some of the rate limit issues in testa and clean up the job: - Set HOMEBREW_GITHUB_API_TOKEN to tell Homebrew to use our CI token to authenticate with the GitHub API. This drastically increases the rate limit. - Combine the two test jobs into a single matrix job. When installing additional shells, just look at the RUNNER_OS env var to decide whether to use apt or brew. - Install Nix with a single build user to speed up the install time. - Source Nix and set the relevant env vars in the install step so we don't forget to do it in other steps that need Nix. - Run go tests with the race detector and code coverage.
1 parent 4b7160e commit 333c193

File tree

2 files changed

+61
-44
lines changed

2 files changed

+61
-44
lines changed

.github/workflows/debug.yaml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: debug
2+
23
on:
34
workflow_dispatch:
45
inputs:
@@ -10,23 +11,47 @@ on:
1011
options:
1112
- macos-12
1213
- ubuntu-latest
14+
1315
permissions:
1416
contents: read
17+
18+
env:
19+
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}"
20+
HOMEBREW_NO_ANALYTICS: 1
21+
HOMEBREW_NO_AUTO_UPDATE: 1
22+
HOMEBREW_NO_EMOJI: 1
23+
HOMEBREW_NO_ENV_HINTS: 1
24+
HOMEBREW_NO_INSTALL_CLEANUP: 1
25+
1526
jobs:
16-
golangci-lint:
27+
debug:
1728
runs-on: ${{ inputs.runner }}
29+
timeout-minutes: 10
1830
steps:
1931
- name: Get rate limits
2032
run: |
21-
curl \
22-
-H "Accept: application/vnd.github+json" \
23-
-H "Authorization: ${{ github.token }}" \
24-
https://api.github.com/rate_limit | jq .
33+
curl https://api.github.com/rate_limit \
34+
-H "Accept: application/vnd.github+json" \
35+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
36+
--show-error \
37+
--silent \
38+
| jq .
2539
- uses: actions/checkout@v3
2640
- uses: actions/setup-go@v3
2741
with:
2842
go-version-file: ./go.mod
43+
- run: |
44+
echo "Starting a tmate session for 10 minutes."
45+
echo
46+
echo "You can connect using the SSH command printed below to get an interactive shell"
47+
echo "on this GitHub Actions runner. Access is limited to the public SSH keys"
48+
echo "associated with your GitHub account."
49+
50+
curl https://api.github.com/users/${{ github.actor }}/keys \
51+
-H "Accept: application/vnd.github+json" \
52+
--show-error \
53+
--silent \
54+
| jq .
2955
- uses: mxschmitt/action-tmate@v3
3056
with:
31-
args: --timeout=10m
3257
limit-access-to-actor: true

.github/workflows/tests.yaml

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@ permissions:
1414
contents: read
1515
pull-requests: read
1616

17+
env:
18+
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}"
19+
HOMEBREW_NO_ANALYTICS: 1
20+
HOMEBREW_NO_AUTO_UPDATE: 1
21+
HOMEBREW_NO_EMOJI: 1
22+
HOMEBREW_NO_ENV_HINTS: 1
23+
HOMEBREW_NO_INSTALL_CLEANUP: 1
24+
1725
jobs:
1826
golangci-lint:
1927
strategy:
2028
matrix:
2129
os: [ubuntu-latest, macos-12]
2230
runs-on: ${{ matrix.os }}
31+
timeout-minutes: 10
2332
steps:
2433
- uses: actions/checkout@v3
2534
- uses: actions/setup-go@v3
@@ -28,11 +37,13 @@ jobs:
2837
cache: false # use golangci cache instead
2938
- name: golangci-lint
3039
uses: golangci/[email protected]
31-
with:
32-
args: --timeout=10m
3340

34-
test-linux:
35-
runs-on: ubuntu-latest
41+
test:
42+
strategy:
43+
matrix:
44+
os: [ubuntu-latest, macos-12]
45+
runs-on: ${{ matrix.os }}
46+
timeout-minutes: 10
3647
steps:
3748
- uses: actions/checkout@v3
3849
- uses: actions/setup-go@v3
@@ -41,42 +52,23 @@ jobs:
4152
cache: true
4253
- name: Build devbox
4354
run: go install ./cmd/devbox
44-
- name: Install additional shells
55+
- name: Install additional shells (dash, zsh)
4556
run: |
46-
sudo apt-get update
47-
sudo apt-get install dash zsh
57+
if [ "$RUNNER_OS" == "Linux" ]; then
58+
sudo apt-get update
59+
sudo apt-get install dash zsh
60+
elif [ "$RUNNER_OS" == "macOS" ]; then
61+
brew update
62+
brew install dash zsh
63+
fi
4864
- name: Install Nix
49-
run: sh <(curl -L https://nixos.org/nix/install) --daemon
50-
- name: Run tests
5165
run: |
66+
sh <(curl -L https://nixos.org/nix/install) --no-modify-profile --daemon --daemon-user-count 1
5267
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
53-
go test ./...
54-
55-
test-darwin:
56-
if: ${{ false }} # disable until we figure out Homebrew rate limiting
57-
runs-on: macos-12
58-
steps:
59-
- uses: actions/checkout@v3
60-
- uses: actions/setup-go@v3
61-
with:
62-
go-version-file: ./go.mod
63-
cache: true
64-
- name: Build devbox
65-
run: go install ./cmd/devbox
66-
- name: Install additional shells
67-
env:
68-
HOMEBREW_NO_ANALYTICS: 1
69-
HOMEBREW_NO_AUTO_UPDATE: 1
70-
HOMEBREW_NO_EMOJI: 1
71-
HOMEBREW_NO_ENV_HINTS: 1
72-
HOMEBREW_NO_INSTALL_CLEANUP: 1
73-
HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }}
74-
run: |
75-
brew update
76-
brew install dash zsh
77-
- name: Install Nix
78-
run: sh <(curl -L https://nixos.org/nix/install) --daemon
68+
nix-build '<nixpkgs>' -A stdenv -A bash -A hello
69+
echo "__ETC_PROFILE_NIX_SOURCED=1" >> $GITHUB_ENV
70+
echo "NIX_PROFILES=$NIX_PROFILES" >> $GITHUB_ENV
71+
echo "NIX_SSL_CERT_FILE=$NIX_SSL_CERT_FILE" >> $GITHUB_ENV
72+
echo "PATH=$PATH" >> $GITHUB_ENV
7973
- name: Run tests
80-
run: |
81-
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
82-
go test ./...
74+
run: go test -race -cover ./...

0 commit comments

Comments
 (0)