Skip to content

Commit b3de825

Browse files
authored
Ci revamp retry docker (#5)
1 parent 80f1c95 commit b3de825

6 files changed

Lines changed: 79 additions & 57 deletions

File tree

.github/workflows/ci.yml

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,77 +3,85 @@ name: CI
33
on:
44
push:
55
branches: [ "main", "ci-revamp-test" ]
6+
tags: [ '*' ]
7+
paths-ignore: [ '*.md' ]
68
pull_request:
79
branches: [ "main", "ci-revamp-test" ]
810

911
env:
1012
CARGO_TERM_COLOR: always
1113
REGISTRY: ghcr.io
14+
IMAGE_NAME: ${{ github.repository }}
1215
UBUNTU_DOCKERFILE: .github/workflows/ubuntu.dockerfile
1316

1417
permissions:
18+
pull-requests: read
1519
contents: read
1620
packages: read
1721

1822
jobs:
19-
build:
23+
set-vars:
2024
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 2
29+
sparse-checkout: |
30+
.github
31+
Cargo.toml
32+
sparse-checkout-cone-mode: false
33+
- id: set-vars
34+
run: ./.github/workflows/set-vars.sh ${GITHUB_REPOSITORY@L}
35+
outputs:
36+
msrv: ${{ steps.set-vars.outputs.msrv }}
37+
should-build: ${{ steps.set-vars.outputs.should_build == 'true' && github.event_name == 'push' }}
38+
container-path: ${{ steps.set-vars.outputs.container_path }}
39+
40+
container-build:
41+
runs-on: ubuntu-latest
42+
needs: set-vars
43+
if: ${{ needs.set-vars.outputs.should-build == 'true' }}
2144
permissions:
22-
contents: read
2345
packages: write
2446
id-token: write
2547

2648
steps:
27-
- uses: actions/checkout@v4
28-
with:
29-
fetch-depth: 1
30-
sparse-checkout: Cargo.toml
31-
- name: Get commit timestamp
32-
run: echo "SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)" >> "$GITHUB_ENV"
33-
- name: Get MSRV
34-
run: echo "MSRV=$(
35-
awk '/^rust-version = "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+"$/ {
36-
print substr($NF, 2, length($NF) - 2)
37-
}' Cargo.toml)" >> "$GITHUB_ENV"
38-
- id: image-name
39-
run: |
40-
echo "name=${{ env.REGISTRY }}/${GITHUB_REPOSITORY@L}-ubuntu" >> "$GITHUB_OUTPUT"
49+
- uses: docker/setup-buildx-action@v3
4150
- uses: docker/login-action@v3
4251
with:
4352
registry: ${{ env.REGISTRY }}
4453
username: ${{ github.actor }}
4554
password: ${{ secrets.GITHUB_TOKEN }}
46-
- uses: docker/setup-buildx-action@v3
4755
- uses: docker/build-push-action@v6
48-
id: docker-build-push-registry
4956
with:
5057
file: ${{ env.UBUNTU_DOCKERFILE }}
51-
tags: ${{ steps.image-name.outputs.name }}:latest
58+
push: true
59+
tags: ${{ needs.set-vars.outputs.container-path }}-ubuntu:latest
5260
labels: org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
53-
cache-from: type=registry,ref=${{ steps.image-name.outputs.name }}:cache
54-
cache-to: |
55-
${{ github.event_name == 'push' &&
56-
format('type=registry,ref={0}:cache,mode=max', steps.image-name.outputs.name) ||
57-
'' }}
58-
outputs: |
59-
type=image,ref=${{ steps.image-name.outputs.name }}:latest,push=${{ github.event_name == 'push' }}
60-
- name: ctr images list
61-
run: sudo ctr images list
62-
- name: Start container
63-
run: docker run --name xwls-test --detach --interactive --tty
64-
${{ steps.image-name.outputs.name }}:latest
65-
- name: Check workspace
66-
run: docker exec --interactive xwls-test
67-
sh -c "cargo check --profile ci --locked --verbose --keep-going --workspace --exclude xwayland-satellite"
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
63+
64+
xwls-build-test:
65+
needs: [container-build, set-vars]
66+
if: ${{ always() && (needs.container-build.result == 'success' || needs.container-build.result == 'skipped') }}
67+
runs-on: ubuntu-latest
68+
container:
69+
image: ${{ needs.set-vars.outputs.container-path }}-ubuntu:latest
70+
credentials:
71+
username: ${{ github.actor }}
72+
password: ${{ secrets.GITHUB_TOKEN }}
73+
74+
steps:
75+
- uses: actions/checkout@v5
76+
- uses: dtolnay/rust-toolchain@master
77+
with:
78+
toolchain: ${{ needs.set-vars.outputs.msrv }}
79+
components: clippy, rustfmt
6880
- name: Build
69-
run: docker exec --interactive xwls-test
70-
sh -c "cargo test --no-run --profile ci --locked --verbose"
81+
run: cargo build --all-targets --profile ci --locked --verbose
7182
- name: Run tests
72-
run: docker exec --interactive xwls-test
73-
sh -c "cargo test --profile ci --locked --verbose --no-fail-fast -- --test-threads 1"
83+
run: cargo test --profile ci --locked --verbose -- --test-threads 1 --nocapture
7484
- name: Format check
75-
run: docker exec --interactive xwls-test
76-
sh -c "cargo fmt --check"
85+
run: cargo fmt --check
7786
- name: Clippy
78-
run: docker exec --interactive xwls-test
79-
sh -c "cargo clippy --profile ci --locked --workspace --all-targets"
87+
run: cargo clippy --all-targets --profile ci --locked --workspace

.github/workflows/set-vars.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
msrv=$(
4+
awk '/^rust-version = "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+"$/ {
5+
print substr($NF, 2, length($NF) - 2)
6+
}' Cargo.toml
7+
)
8+
if [ -z $msrv ]; then
9+
printf "Could not determine Rust toolchain version\n"
10+
exit 1
11+
fi
12+
13+
if ! $(git diff HEAD~1 --quiet -- "$UBUNTU_DOCKERFILE") ||
14+
$(git describe --candidates=0); then
15+
should_build=true
16+
else
17+
should_build=false
18+
fi
19+
20+
echo "msrv=$msrv" >> "$GITHUB_OUTPUT"
21+
echo "should_build=$should_build" >> "$GITHUB_OUTPUT"
22+
echo "container_path=$REGISTRY/$1" >> "$GITHUB_OUTPUT"
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
FROM ubuntu:24.04
1+
FROM ubuntu:latest
22

33
ARG DEBIAN_FRONTEND=noninteractive
44
ENV TZ=Etc/UTC
5-
ENV CARGO_HOME=/cargo RUSTUP_HOME=/rustup
65
RUN apt-get update \
7-
&& apt-get install -y xwayland libxcb1 clang libxcb-cursor0 libxcb-cursor-dev curl pkg-config libegl1 \
6+
&& apt-get install -y xwayland libxcb1 clang libxcb-cursor0 libxcb-cursor-dev pkg-config libegl1 \
87
&& rm -r /var/lib/apt/lists/*
9-
ENV MSRV=1.83.0
10-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
11-
&& . "/cargo/env" \
12-
&& rustup toolchain install $MSRV \
13-
&& rustup default $MSRV
148
RUN mkdir /run/xwls-test
15-
ENV PATH="/cargo/bin:$PATH" XDG_RUNTIME_DIR="/run/xwls-test"
16-
COPY . /xwls
17-
WORKDIR /xwls
9+
ENV XDG_RUNTIME_DIR="/run/xwls-test"

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rustix = "0.38.31"
1212
all = "deny"
1313

1414
[workspace.package]
15-
rust-version = "1.83.0"
15+
rust-version = "1.87.0"
1616

1717
[package]
1818
name = "xwayland-satellite"

tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl Fixture {
131131
// wait for connection
132132
let fd = unsafe { BorrowedFd::borrow_raw(testwl.poll_fd().as_raw_fd()) };
133133
let pollfd = PollFd::from_borrowed_fd(fd, PollFlags::IN);
134-
assert!(poll(&mut [pollfd.clone()], 100).unwrap() > 0);
134+
assert!(poll(&mut [pollfd.clone()], -1).unwrap() > 0);
135135
testwl.dispatch();
136136

137137
let try_bool_timeout = |b: &AtomicBool| {

testwl/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::{hash_map, HashMap, HashSet};
22
use std::io::Read;
3-
use std::io::Write;
3+
use std::io::{PipeWriter, Write};
44
use std::os::fd::{AsFd, BorrowedFd, OwnedFd};
55
use std::os::unix::net::UnixStream;
66
use std::sync::{Arc, Mutex, OnceLock};
@@ -1026,7 +1026,7 @@ impl Dispatch<WlDataOffer, Vec<PasteData>> for State {
10261026
.position(|data| data.mime_type == mime_type)
10271027
.unwrap_or_else(|| panic!("Invalid mime type: {mime_type}"));
10281028

1029-
let mut stream = UnixStream::from(fd);
1029+
let mut stream = PipeWriter::from(fd);
10301030
stream.write_all(&data[pos].data).unwrap();
10311031
}
10321032
wl_data_offer::Request::Destroy => {}

0 commit comments

Comments
 (0)