@@ -3,77 +3,85 @@ name: CI
33on :
44 push :
55 branches : [ "main", "ci-revamp-test" ]
6+ tags : [ '*' ]
7+ paths-ignore : [ '*.md' ]
68 pull_request :
79 branches : [ "main", "ci-revamp-test" ]
810
911env :
1012 CARGO_TERM_COLOR : always
1113 REGISTRY : ghcr.io
14+ IMAGE_NAME : ${{ github.repository }}
1215 UBUNTU_DOCKERFILE : .github/workflows/ubuntu.dockerfile
1316
1417permissions :
18+ pull-requests : read
1519 contents : read
1620 packages : read
1721
1822jobs :
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
0 commit comments