Skip to content

CI

CI #3

Workflow file for this run

name: CI
on:
merge_group:
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
run: rustup update nightly && rustup default nightly && rustup component add rustfmt clippy
- name: Check the code formatting with rustfmt
run: cargo fmt --all -- --check
- name: Ensure there are no warnings with Clippy
run: cargo clippy --all -- -Dwarnings
- name: Check if the configuration is correct
run: |
cargo run -- create-lists
cargo run -- check-config
test:
name: Testing
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
channel: [nightly]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ matrix.channel }}
shell: bash
run: rustup update --no-self-update $CHANNEL && rustup default $CHANNEL
env:
CHANNEL: ${{ matrix.channel }}
- name: Build Crater
shell: bash
run: cargo build
- name: Run Crater tests
shell: bash
run: |
cargo run -- create-lists
cargo test
minicrater:
name: Minicrater
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
run: rustup update --no-self-update nightly && rustup default nightly
- name: Run minicrater
shell: bash
run: |
cargo run -- create-lists
cargo test -- --ignored --nocapture --test-threads 1
env:
MINICRATER_FAST_WORKSPACE_INIT: 1
MINICRATER_SHOW_OUTPUT: 1
docker-build:
name: Build the Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build -t crater .
- name: Prepare the Docker image to be uploaded
run: |
mkdir -p /tmp/docker-images
docker save crater | gzip > /tmp/docker-images/crater.tar.gz
- name: Upload the image to GitHub Actions artifacts
uses: actions/upload-artifact@v4
with:
name: docker-images
path: /tmp/docker-images
docker-upload:
name: Upload the Docker images to ECR
runs-on: ubuntu-latest
needs:
- lint
- test
- minicrater
- docker-build
steps:
- name: Download the image from GitHub Actions artifacts
uses: actions/download-artifact@v4
with:
name: docker-images
path: docker-images
- name: Load the downloaded image
run: cat docker-images/crater.tar.gz | gunzip | docker load
- name: Upload the Docker image to ECR
uses: rust-lang/simpleinfra/github-actions/upload-docker-image@master
with:
image: crater
repository: crater
region: us-west-1
aws_access_key_id: "${{ secrets.aws_access_key_id }}"
aws_secret_access_key: "${{ secrets.aws_secret_access_key }}"
if: github.ref == 'refs/heads/auto'
conclusion:
needs: [docker-upload]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
# when the workflow is canceled manually.
#
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: Conclusion
run: |
# Print the dependent jobs to see them in the CI log
jq -C <<< '${{ toJson(needs) }}'
# Check if all jobs that we depend on (in the needs array) were successful.
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'