ci: Download Alpine and musl cross-compiler #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust | |
| on: | |
| push: | |
| branches: ["master"] | |
| pull_request: | |
| branches: ["master"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache musl toolchain | |
| uses: actions/cache@v3 | |
| id: cache-musl | |
| with: | |
| path: musl-cross-compiler | |
| key: musl-toolchain-x86_64-${{ runner.os }} | |
| - name: Build musl cross-compiler | |
| if: steps.cache-musl.outputs.cache-hit != 'true' | |
| run: | | |
| git clone https://github.com/richfelker/musl-cross-make.git | |
| cd musl-cross-make | |
| cat > config.mak << 'EOF' | |
| TARGET = x86_64-linux-musl | |
| OUTPUT = $(PWD)/../musl-cross-compiler | |
| DL_CMD = wget -c -O | |
| COMMON_CONFIG += --disable-nls | |
| GCC_CONFIG += --enable-languages=c,c++ | |
| COMMON_CONFIG += CFLAGS="-g0 -Os" CXXFLAGS="-g0 -Os" LDFLAGS="-s" | |
| EOF | |
| make -j$(nproc) | |
| make install | |
| - name: Setup Alpine rootfs | |
| run: | | |
| mkdir -p alpine-rootfs | |
| curl -L https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/x86_64/alpine-minirootfs-3.22.1-x86_64.tar.gz | tar -xz -C alpine-rootfs | |
| - name: Install Protoc | |
| uses: arduino/setup-protoc@v3 | |
| - name: Install musl target for Rust | |
| run: rustup target add x86_64-unknown-linux-musl | |
| - name: Build | |
| run: cargo build --verbose | |
| - name: Run tests | |
| run: cargo test --verbose |