Skip to content

Switch back to the example alpine builder in CI #2851

Switch back to the example alpine builder in CI

Switch back to the example alpine builder in CI #2851

Workflow file for this run

name: CI
on:
push:
# Avoid duplicate builds on PRs.
branches:
- main
pull_request:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Rust toolchain
# Most of the time this will be a no-op, since GitHub releases new images every week
# which include the latest stable release of Rust, Rustup, Clippy and rustfmt.
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Clippy
# Using --all-targets so tests are checked and --deny to fail on warnings.
# Not using --locked here and below since Cargo.lock is in .gitignore.
run: cargo clippy --all-targets --all-features -- --deny warnings
- name: rustfmt
run: cargo fmt -- --check
- name: Check docs
# Using RUSTDOCFLAGS until `cargo doc --check` is stabilised:
# https://github.com/rust-lang/cargo/issues/10025
run: RUSTDOCFLAGS="-D warnings" cargo doc --all-features --document-private-items --no-deps
unit-test:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Run unit tests
run: cargo test --all-features
integration-test:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install musl-tools
run: sudo apt-get install musl-tools --no-install-recommends
- name: Update Rust toolchain
run: rustup update
- name: Install Rust linux-musl target
run: rustup target add x86_64-unknown-linux-musl
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Install Pack CLI
uses: buildpacks/github-actions/[email protected]
- name: Run integration tests
# Runs only tests annotated with the `ignore` attribute (which in this repo, are the integration tests).
run: cargo test -- --ignored
- name: Check libcnb-test has cleaned up test containers, volumes and images
run: |
if [[ -n "$(docker ps --all --quiet)" ]]; then
docker ps --all
echo "Unexpected Docker containers left behind!"
exit 1
fi
if [[ -n "$(docker volume ls --quiet)" ]]; then
docker volume ls
echo "Unexpected Docker volumes left behind!"
exit 1
fi
if [[ -n "$(docker images --all --quiet '*libcnb*')" ]]; then
docker images --all '*libcnb*'
echo "Unexpected Docker images left behind!"
exit 1
fi
- name: Compile and package examples/basics
run: cargo run --package libcnb-cargo -- libcnb package
working-directory: ./examples/basics
- name: Pack build using examples/basics
# Uses a non-libc image to validate the static musl cross-compilation.
run: pack build example-basics --force-color --builder cnbs/sample-builder:alpine --trust-builder --trust-extra-buildpacks --buildpack packaged/x86_64-unknown-linux-musl/debug/libcnb-examples_basics --path examples/