xwayland-satellite/.github/workflows/ci.yml

87 lines
2.6 KiB
YAML

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:
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:
packages: write
id-token: write
steps:
- 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: ${{ needs.set-vars.outputs.msrv }}
components: clippy, rustfmt
- name: Build
run: cargo build --all-targets --profile ci --locked --verbose
- name: Run tests
run: cargo test --profile ci --locked --verbose -- --test-threads 1 --nocapture
- name: Format check
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets --profile ci --locked --workspace