ci: rewrite from ground up
This commit is contained in:
parent
d759c64681
commit
9052dd556a
4 changed files with 46 additions and 81 deletions
101
.github/workflows/ci.yml
vendored
101
.github/workflows/ci.yml
vendored
|
|
@ -8,77 +8,46 @@ on:
|
|||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
UBUNTU_DOCKERFILE: .github/workflows/ubuntu.dockerfile
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
|
||||
jobs:
|
||||
check-should-build-container:
|
||||
ci:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: read
|
||||
contents: read
|
||||
steps:
|
||||
- if: ${{ github.event_name == 'push' }}
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
sparse-checkout: .github
|
||||
- id: changed
|
||||
uses: tj-actions/changed-files@v45
|
||||
with:
|
||||
files: ${{ env.UBUNTU_DOCKERFILE }}
|
||||
- id: name
|
||||
run: echo "container_path=${{ env.REGISTRY }}/${GITHUB_REPOSITORY@L}" >> "$GITHUB_OUTPUT"
|
||||
outputs:
|
||||
should-build: ${{ steps.changed.outputs.any_changed }}
|
||||
container-path: ${{ steps.name.outputs.container_path }}
|
||||
|
||||
ubuntu-build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check-should-build-container
|
||||
if: ${{ needs.check-should-build-container.outputs.should-build == 'true' }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
packages: read
|
||||
|
||||
steps:
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Get MSRV
|
||||
id: msrv
|
||||
run: |
|
||||
echo "msrv=$(
|
||||
awk '/^rust-version = "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+"$/ {
|
||||
print substr($NF, 2, length($NF) - 2)
|
||||
}' Cargo.toml)" >> "$GITHUB_OUTPUT"
|
||||
- name: Set XDG_RUNTIME_DIR
|
||||
id: xrd
|
||||
run: echo "testdir=$PWD/test-xwls" >> "$GITHUB_OUTPUT"
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y xwayland clang libxcb1 libxcb-cursor0 libxcb-cursor-dev pkg-config libegl1
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: docker/build-push-action@v6
|
||||
with:
|
||||
file: ${{ env.UBUNTU_DOCKERFILE }}
|
||||
push: true
|
||||
tags: ${{ needs.check-should-build-container.outputs.container-path }}-ubuntu:latest
|
||||
labels: org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
build:
|
||||
needs: [ubuntu-build, check-should-build-container]
|
||||
if: ${{ always() && (needs.ubuntu-build.result == 'success' || needs.ubuntu-build.result == 'skipped') }}
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ needs.check-should-build-container.outputs.container-path }}-ubuntu:latest
|
||||
credentials:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build
|
||||
run: cargo build --release --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
||||
- name: Format check
|
||||
run: cargo fmt --check
|
||||
- name: Clippy
|
||||
run: cargo clippy --workspace --all-targets
|
||||
toolchain: ${{ steps.msrv.outputs.msrv }}
|
||||
components: clippy, rustfmt
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Build
|
||||
run: cargo build --all-targets --profile ci --locked --verbose
|
||||
- name: Run tests
|
||||
run: |
|
||||
mkdir "$XDG_RUNTIME_DIR"
|
||||
cargo test --profile ci --locked --verbose -- --test-threads 1 --nocapture
|
||||
env:
|
||||
XDG_RUNTIME_DIR: ${{ steps.xrd.outputs.testdir }}
|
||||
- name: Format check
|
||||
run: cargo fmt --check
|
||||
- name: Clippy
|
||||
run: cargo clippy --profile ci --locked --workspace --all-targets
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue