Skip to content

Commit

Permalink
Refactor CI: Extract .github/actions/compile-make
Browse files Browse the repository at this point in the history
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
  • Loading branch information
NobodyXu committed Apr 7, 2024
1 parent 0d10b47 commit bb1cb04
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 46 deletions.
37 changes: 37 additions & 0 deletions .github/actions/compile-make/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Compile make
description: compile-make
inputs:
version:
description: make version
required: true
workaround:
description: enable workaround for _alloc bug
required: false
default: "false"

runs:
using: composite
steps:
- name: Cache make compiled
if: ${{ !startsWith(runner.os, 'windows') }}
id: cache-maka
uses: actions/cache@v4
with:
path: /usr/local/bin/make-${{ inputs.version }}
key: v1-${{ runner.os }}-make-${{ inputs.version }}

# Compile it from source (temporarily)
- name: Make GNU Make from source
if: ${{ !startsWith(runner.os, 'windows') && steps.cache-make.outputs.cache-hit != 'true' }}
env:
VERSION: ${{ inputs.version }}
WORKAROUND: ${{ inputs.workaround }}
shell: bash
run: |
curl "https://ftp.gnu.org/gnu/make/make-${VERSION}.tar.gz" | tar xz
pushd "make-${VERSION}"
./configure
[[ "$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"
make -j 4
popd
cp -p "make-${VERSION}/make" "/usr/local/bin/make-${VERSION}"
75 changes: 29 additions & 46 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,37 @@ jobs:
rust: [stable, beta, nightly]
os: [ubuntu-latest, macos-14, windows-latest]
steps:
- uses: actions/checkout@master
- name: Install Rust (rustup)
run: |
rustup toolchain install ${{ matrix.rust }} --no-self-update --profile minimal
rustup default ${{ matrix.rust }}
shell: bash

- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@master
- name: Install Rust (rustup)
run: |
rustup toolchain install ${{ matrix.rust }} --no-self-update --profile minimal
rustup default ${{ matrix.rust }}
shell: bash

- run: cargo test --locked
- uses: Swatinem/rust-cache@v2

- name: Cache make compiled
if: ${{ !startsWith(matrix.os, 'windows') }}
id: cache-make
uses: actions/cache@v4
with:
path: /usr/local/bin/make
key: ${{ runner.os }}-make-4.4.1
- run: cargo test --locked

# Compile it from source (temporarily)
- name: Make GNU Make from source
if: ${{ !startsWith(matrix.os, 'windows') && steps.cache-make.outputs.cache-hit != 'true' }}
env:
VERSION: "4.4.1"
shell: bash
run: |
curl "https://ftp.gnu.org/gnu/make/make-${VERSION}.tar.gz" | tar xz
pushd "make-${VERSION}"
./configure
make -j 4
popd
cp -p "make-${VERSION}/make" /usr/local/bin
- name: Compile make 4.4.1
uses: ./.github/actions/compile-make
with:
version: 4.4.1

- name: Test against GNU Make from source
if: ${{ !startsWith(matrix.os, 'windows') }}
shell: bash
run: cargo test --locked
env:
MAKE: /usr/local/bin/make
- name: Test against GNU Make 4.4.1
if: ${{ !startsWith(matrix.os, 'windows') }}
shell: bash
run: cargo test --locked
env:
MAKE: /usr/local/bin/make-4.4.1

rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- run: cargo fmt -- --check
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- run: cargo fmt -- --check

publish_docs:
name: Publish Documentation
Expand All @@ -86,12 +69,12 @@ jobs:
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
steps:
- uses: actions/checkout@master
- name: Install Rust (rustup)
run: rustup toolchain install nightly --no-self-update --profile minimal
shell: bash
- uses: actions/checkout@master
- name: Install Rust (rustup)
run: rustup toolchain install nightly --no-self-update --profile minimal
shell: bash

- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2

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

0 comments on commit bb1cb04

Please sign in to comment.