ci: restore dependency-storing dockerfile
This commit is contained in:
parent
9052dd556a
commit
fe1796cfa7
4 changed files with 95 additions and 29 deletions
90
.github/workflows/ci.yml
vendored
90
.github/workflows/ci.yml
vendored
|
|
@ -3,51 +3,85 @@ name: CI
|
|||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
tags: [ '*' ]
|
||||
paths-ignore: [ '*.md' ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
UBUNTU_DOCKERFILE: .github/workflows/ubuntu.dockerfile
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
contents: read
|
||||
packages: read
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
set-vars:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 2
|
||||
sparse-checkout: |
|
||||
.github
|
||||
Cargo.toml
|
||||
sparse-checkout-cone-mode: false
|
||||
- id: set-vars
|
||||
run: ./.github/workflows/set-vars.sh ${GITHUB_REPOSITORY@L}
|
||||
outputs:
|
||||
msrv: ${{ steps.set-vars.outputs.msrv }}
|
||||
should-build: ${{ steps.set-vars.outputs.should_build == 'true' && github.event_name == 'push' }}
|
||||
container-path: ${{ steps.set-vars.outputs.container_path }}
|
||||
|
||||
container-build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: set-vars
|
||||
if: ${{ needs.set-vars.outputs.should-build == 'true' }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- 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: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
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.set-vars.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
|
||||
|
||||
xwls-build-test:
|
||||
needs: [container-build, set-vars]
|
||||
if: ${{ always() && (needs.container-build.result == 'success' || needs.container-build.result == 'skipped') }}
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ needs.set-vars.outputs.container-path }}-ubuntu:latest
|
||||
credentials:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
toolchain: ${{ steps.msrv.outputs.msrv }}
|
||||
toolchain: ${{ needs.set-vars.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 }}
|
||||
run: cargo test --profile ci --locked --verbose -- --test-threads 1 --nocapture
|
||||
- name: Format check
|
||||
run: cargo fmt --check
|
||||
- name: Clippy
|
||||
run: cargo clippy --profile ci --locked --workspace --all-targets
|
||||
run: cargo clippy --all-targets --profile ci --locked --workspace
|
||||
|
|
|
|||
23
.github/workflows/set-vars.sh
vendored
Executable file
23
.github/workflows/set-vars.sh
vendored
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
msrv=$(
|
||||
awk '/^rust-version = "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+"$/ {
|
||||
print substr($NF, 2, length($NF) - 2)
|
||||
}' Cargo.toml
|
||||
)
|
||||
if [ -z $msrv ]; then
|
||||
printf "Could not determine Rust toolchain version\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
||||
if ! git diff HEAD~1 --quiet -- "$UBUNTU_DOCKERFILE" ||
|
||||
git describe --candidates=0; then
|
||||
should_build=true
|
||||
else
|
||||
should_build=false
|
||||
fi
|
||||
|
||||
echo "msrv=$msrv" >> "$GITHUB_OUTPUT"
|
||||
echo "should_build=$should_build" >> "$GITHUB_OUTPUT"
|
||||
echo "container_path=$REGISTRY/$1" >> "$GITHUB_OUTPUT"
|
||||
9
.github/workflows/ubuntu.dockerfile
vendored
Normal file
9
.github/workflows/ubuntu.dockerfile
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
FROM ubuntu:latest
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=Etc/UTC
|
||||
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 mkdir /run/xwls-test
|
||||
ENV XDG_RUNTIME_DIR="/run/xwls-test"
|
||||
Loading…
Add table
Add a link
Reference in a new issue