Skip to content

Run Rust checks on CI #97

Run Rust checks on CI

Run Rust checks on CI #97

Workflow file for this run

name: html-build CI
on:
pull_request:
branches: ['main']
push:
branches: ['main']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
static-checks:
name: Static Checks
runs-on: ubuntu-latest
steps:
- name: Checkout whatwg/html-build
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run tests
run: cargo test
- name: Shellcheck
run: |
shellcheck *.sh
shellcheck ci-build/*.sh
build-and-test-image:
name: Build and Test Image
runs-on: ubuntu-latest
steps:
- name: Checkout whatwg/html-build
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Docker build
run: ci-build/docker-build.sh
- name: Checkout whatwg/html
uses: actions/checkout@v3
with:
repository: whatwg/html
path: html
fetch-depth: 2
- name: Test against whatwg/html
run: |
mkdir output
bash ci-build/docker-run.sh "$GITHUB_WORKSPACE/html" output
publish:
name: Publish
runs-on: ubuntu-latest
needs: [static-checks, build-and-test-image]
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
permissions:
contents: read
packages: write
steps:
- name: Docker login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker push
run: |
docker tag "$REGISTRY/$IMAGE_NAME" "$REGISTRY/$IMAGE_NAME:$GITHUB_SHA"
docker tag "$REGISTRY/$IMAGE_NAME" "$REGISTRY/$IMAGE_NAME:latest"
docker push "$REGISTRY/$IMAGE_NAME:$GITHUB_SHA"
docker push "$REGISTRY/$IMAGE_NAME:latest"