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:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
REGISTRY: ghcr.io
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
UBUNTU_DOCKERFILE: .github/workflows/ubuntu.dockerfile
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-should-build-container:
|
ci:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
pull-requests: read
|
|
||||||
contents: read
|
contents: read
|
||||||
steps:
|
packages: read
|
||||||
- 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
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: docker/setup-buildx-action@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: docker/login-action@v3
|
- 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:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
toolchain: ${{ steps.msrv.outputs.msrv }}
|
||||||
username: ${{ github.actor }}
|
components: clippy, rustfmt
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
- uses: Swatinem/rust-cache@v2
|
||||||
- uses: docker/build-push-action@v6
|
- name: Build
|
||||||
with:
|
run: cargo build --all-targets --profile ci --locked --verbose
|
||||||
file: ${{ env.UBUNTU_DOCKERFILE }}
|
- name: Run tests
|
||||||
push: true
|
run: |
|
||||||
tags: ${{ needs.check-should-build-container.outputs.container-path }}-ubuntu:latest
|
mkdir "$XDG_RUNTIME_DIR"
|
||||||
labels: org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
cargo test --profile ci --locked --verbose -- --test-threads 1 --nocapture
|
||||||
cache-from: type=gha
|
env:
|
||||||
cache-to: type=gha,mode=max
|
XDG_RUNTIME_DIR: ${{ steps.xrd.outputs.testdir }}
|
||||||
|
- name: Format check
|
||||||
build:
|
run: cargo fmt --check
|
||||||
needs: [ubuntu-build, check-should-build-container]
|
- name: Clippy
|
||||||
if: ${{ always() && (needs.ubuntu-build.result == 'success' || needs.ubuntu-build.result == 'skipped') }}
|
run: cargo clippy --profile ci --locked --workspace --all-targets
|
||||||
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
|
|
||||||
|
|
|
||||||
14
.github/workflows/ubuntu.dockerfile
vendored
14
.github/workflows/ubuntu.dockerfile
vendored
|
|
@ -1,14 +0,0 @@
|
||||||
FROM ubuntu:24.04
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
ENV TZ=Etc/UTC
|
|
||||||
ENV CARGO_HOME=/cargo RUSTUP_HOME=/rustup
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get install -y xwayland libxcb1 clang libxcb-cursor0 libxcb-cursor-dev curl pkg-config libegl1 \
|
|
||||||
&& rm -r /var/lib/apt/lists/*
|
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
|
|
||||||
&& . "/cargo/env" \
|
|
||||||
&& rustup toolchain install stable \
|
|
||||||
&& rustup default stable
|
|
||||||
RUN mkdir /run/xwls-test
|
|
||||||
ENV PATH="/cargo/bin:$PATH" XDG_RUNTIME_DIR="/run/xwls-test"
|
|
||||||
10
Cargo.toml
10
Cargo.toml
|
|
@ -11,10 +11,14 @@ rustix = "0.38.31"
|
||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
all = "deny"
|
all = "deny"
|
||||||
|
|
||||||
|
[workspace.package]
|
||||||
|
rust-version = "1.83.0"
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "xwayland-satellite"
|
name = "xwayland-satellite"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
rust-version.workspace = true
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
@ -51,3 +55,9 @@ testwl = { path = "testwl" }
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
anyhow = "1.0.98"
|
anyhow = "1.0.98"
|
||||||
vergen-gitcl = "1.0.8"
|
vergen-gitcl = "1.0.8"
|
||||||
|
|
||||||
|
[profile.ci]
|
||||||
|
inherits = "dev"
|
||||||
|
# Shrink bloat in ./target which negatively affects build caching
|
||||||
|
incremental = false
|
||||||
|
debug = false
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ impl Fixture {
|
||||||
// wait for connection
|
// wait for connection
|
||||||
let fd = unsafe { BorrowedFd::borrow_raw(testwl.poll_fd().as_raw_fd()) };
|
let fd = unsafe { BorrowedFd::borrow_raw(testwl.poll_fd().as_raw_fd()) };
|
||||||
let pollfd = PollFd::from_borrowed_fd(fd, PollFlags::IN);
|
let pollfd = PollFd::from_borrowed_fd(fd, PollFlags::IN);
|
||||||
assert!(poll(&mut [pollfd.clone()], 100).unwrap() > 0);
|
assert!(poll(&mut [pollfd.clone()], -1).unwrap() > 0);
|
||||||
testwl.dispatch();
|
testwl.dispatch();
|
||||||
|
|
||||||
let try_bool_timeout = |b: &AtomicBool| {
|
let try_bool_timeout = |b: &AtomicBool| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue