Skip to content

Commit aad1156

Browse files
committed
Workflow refactoring
1 parent ebfc3b0 commit aad1156

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/Requirements:/ { in_section=1; next }
2+
in_section && /^- / { print substr($0, 3); last_dep=NR }
3+
NR > last_dep && in_section { exit }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
cache_dir="${HOME}/apt-cache"
4+
5+
set -x
6+
7+
mkdir -p "$cache_dir"
8+
sudo apt -o Dir::Cache::Archives="$cache_dir" update >/dev/null 2>&1
9+
sudo apt -o Dir::Cache::Archives="$cache_dir" install -y clang >/dev/null 2>&1
10+
while read -r pkg; do
11+
sudo apt -o Dir::Cache::Archives="$cache_dir" install -y "$pkg" >/dev/null 2>&1
12+
done <apt-deps.txt
13+
14+
sudo rm -rf "${cache_dir}/partial" "${cache_dir}/lock"

.github/workflows/build.yaml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,14 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v5
1414
- name: Find dependency list
15-
run: |
16-
awk '
17-
/Requirements:/ { in_section=1; next }
18-
in_section && /^- / { print substr($0, 3); last_dep=NR }
19-
NR > last_dep && in_section { exit }
20-
' README.md > apt-deps.txt
21-
cat apt-deps.txt
15+
run: awk -f ./.github/scripts/extract_dependencies.awk README.md | tee apt-deps.txt
2216
- name: Cache apt packages
2317
uses: actions/cache@v4
2418
with:
2519
path: ~/apt-cache
2620
key: ${{ runner.os }}-apt-${{ hashFiles('apt-deps.txt') }}
2721
- name: Install dependencies with cache
28-
run: |
29-
mkdir -p $HOME/apt-cache
30-
sudo apt-get -o Dir::Cache::Archives="$HOME/apt-cache" update
31-
sudo apt-get -o Dir::Cache::Archives="$HOME/apt-cache" install -y clang $(cat apt-deps.txt)
32-
sudo rm -rf $HOME/apt-cache/partial $HOME/apt-cache/lock
22+
run: bash ./.github/scripts/fetch_dependencies.sh
3323
- run: clang nob.c -o nob
3424
- name: Build with default configuration
3525
run: ./nob
@@ -38,6 +28,6 @@ jobs:
3828
env:
3929
WPC_HELPER: 0
4030
- name: Build using Clang instead of GCC
41-
run: |
31+
run: |-
4232
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
4333
./nob

0 commit comments

Comments
 (0)