Skip to content

Commit bb1cb04

Browse files
committed
Refactor CI: Extract .github/actions/compile-make
Signed-off-by: Jiahao XU <[email protected]>
1 parent 0d10b47 commit bb1cb04

File tree

2 files changed

+66
-46
lines changed

2 files changed

+66
-46
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Compile make
2+
description: compile-make
3+
inputs:
4+
version:
5+
description: make version
6+
required: true
7+
workaround:
8+
description: enable workaround for _alloc bug
9+
required: false
10+
default: "false"
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Cache make compiled
16+
if: ${{ !startsWith(runner.os, 'windows') }}
17+
id: cache-maka
18+
uses: actions/cache@v4
19+
with:
20+
path: /usr/local/bin/make-${{ inputs.version }}
21+
key: v1-${{ runner.os }}-make-${{ inputs.version }}
22+
23+
# Compile it from source (temporarily)
24+
- name: Make GNU Make from source
25+
if: ${{ !startsWith(runner.os, 'windows') && steps.cache-make.outputs.cache-hit != 'true' }}
26+
env:
27+
VERSION: ${{ inputs.version }}
28+
WORKAROUND: ${{ inputs.workaround }}
29+
shell: bash
30+
run: |
31+
curl "https://ftp.gnu.org/gnu/make/make-${VERSION}.tar.gz" | tar xz
32+
pushd "make-${VERSION}"
33+
./configure
34+
[[ "$WORKAROUND" = "true" ]] && sed -i 's/#if !defined __alloca \&\& !defined __GNU_LIBRARY__/#if !defined __alloca \&\& defined __GNU_LIBRARY__/g; s/#ifndef __GNU_LIBRARY__/#ifdef __GNU_LIBRARY__/g' "./glob/glob.c"
35+
make -j 4
36+
popd
37+
cp -p "make-${VERSION}/make" "/usr/local/bin/make-${VERSION}"

.github/workflows/main.yml

Lines changed: 29 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,54 +13,37 @@ jobs:
1313
rust: [stable, beta, nightly]
1414
os: [ubuntu-latest, macos-14, windows-latest]
1515
steps:
16-
- uses: actions/checkout@master
17-
- name: Install Rust (rustup)
18-
run: |
19-
rustup toolchain install ${{ matrix.rust }} --no-self-update --profile minimal
20-
rustup default ${{ matrix.rust }}
21-
shell: bash
22-
23-
- uses: Swatinem/rust-cache@v2
16+
- uses: actions/checkout@master
17+
- name: Install Rust (rustup)
18+
run: |
19+
rustup toolchain install ${{ matrix.rust }} --no-self-update --profile minimal
20+
rustup default ${{ matrix.rust }}
21+
shell: bash
2422

25-
- run: cargo test --locked
23+
- uses: Swatinem/rust-cache@v2
2624

27-
- name: Cache make compiled
28-
if: ${{ !startsWith(matrix.os, 'windows') }}
29-
id: cache-make
30-
uses: actions/cache@v4
31-
with:
32-
path: /usr/local/bin/make
33-
key: ${{ runner.os }}-make-4.4.1
25+
- run: cargo test --locked
3426

35-
# Compile it from source (temporarily)
36-
- name: Make GNU Make from source
37-
if: ${{ !startsWith(matrix.os, 'windows') && steps.cache-make.outputs.cache-hit != 'true' }}
38-
env:
39-
VERSION: "4.4.1"
40-
shell: bash
41-
run: |
42-
curl "https://ftp.gnu.org/gnu/make/make-${VERSION}.tar.gz" | tar xz
43-
pushd "make-${VERSION}"
44-
./configure
45-
make -j 4
46-
popd
47-
cp -p "make-${VERSION}/make" /usr/local/bin
27+
- name: Compile make 4.4.1
28+
uses: ./.github/actions/compile-make
29+
with:
30+
version: 4.4.1
4831

49-
- name: Test against GNU Make from source
50-
if: ${{ !startsWith(matrix.os, 'windows') }}
51-
shell: bash
52-
run: cargo test --locked
53-
env:
54-
MAKE: /usr/local/bin/make
32+
- name: Test against GNU Make 4.4.1
33+
if: ${{ !startsWith(matrix.os, 'windows') }}
34+
shell: bash
35+
run: cargo test --locked
36+
env:
37+
MAKE: /usr/local/bin/make-4.4.1
5538

5639
rustfmt:
5740
name: Rustfmt
5841
runs-on: ubuntu-latest
5942
steps:
60-
- uses: actions/checkout@master
61-
- name: Install Rust
62-
run: rustup update stable && rustup default stable && rustup component add rustfmt
63-
- run: cargo fmt -- --check
43+
- uses: actions/checkout@master
44+
- name: Install Rust
45+
run: rustup update stable && rustup default stable && rustup component add rustfmt
46+
- run: cargo fmt -- --check
6447

6548
publish_docs:
6649
name: Publish Documentation
@@ -86,12 +69,12 @@ jobs:
8669
matrix:
8770
os: [ubuntu-latest, macos-14, windows-latest]
8871
steps:
89-
- uses: actions/checkout@master
90-
- name: Install Rust (rustup)
91-
run: rustup toolchain install nightly --no-self-update --profile minimal
92-
shell: bash
72+
- uses: actions/checkout@master
73+
- name: Install Rust (rustup)
74+
run: rustup toolchain install nightly --no-self-update --profile minimal
75+
shell: bash
9376

94-
- uses: taiki-e/install-action@cargo-hack
95-
- uses: Swatinem/rust-cache@v2
77+
- uses: taiki-e/install-action@cargo-hack
78+
- uses: Swatinem/rust-cache@v2
9679

97-
- run: cargo hack check --lib --rust-version --ignore-private --locked
80+
- run: cargo hack check --lib --rust-version --ignore-private --locked

0 commit comments

Comments
 (0)