Skip to content

Commit

Permalink
ci: run on merge to main, also build docker
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah committed Oct 6, 2024
1 parent 3e40940 commit 53a1edb
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 149 deletions.
79 changes: 35 additions & 44 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,45 @@
name: CI
name: CI/CD
on:
workflow_call:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
fmt:
name: Check Formatting
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2

- name: Check formatting
run: cargo fmt --check --all

check:
name: Lint and Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
env:
CI_IS_DEFAULT_BRANCH: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
CI_IS_TAG: ${{ startsWith(github.ref, 'refs/tags/') }}

- name: Clippy lints
run: cargo clippy --all --all-features --all-targets --no-deps -- -D warnings
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

- name: Cargo Doc
run: RUSTDOCFLAGS="-D warnings" cargo doc --all --all-features --no-deps --document-private-items

test:
name: Run Tests on all platforms
strategy:
matrix:
runs-on: ["ubuntu-24.04", "windows-2022", "macos-14"]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2

- name: Test
run: cargo test --all --all-features --all-targets

deny:
name: Run cargo deny
runs-on: ubuntu-22.04
jobs:
check-inputs:
runs-on: ubuntu-24.04
outputs:
CI_CARGO_PROFILE: ${{ steps.set-profile.outputs.CI_CARGO_PROFILE }}
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
- name: Set CI_CARGO_PROFILE
id: set-profile
run: |
if [[ ${CI_IS_DEFAULT_BRANCH} == 'true' ]]; then
CI_CARGO_PROFILE="artifact" >> $GITHUB_OUTPUT
else
CI_CARGO_PROFILE="artifact-dev" >> $GITHUB_OUTPUT
fi
echo "CI_CARGO_PROFILE=${CI_CARGO_PROFILE}" >> $GITHUB_OUTPUT
echo "CI_CARGO_PROFILE=${CI_CARGO_PROFILE}"
rust:
needs: check-inputs
uses: ./.github/workflows/rust.yaml
with:
cargo-profile: ${{ needs.check-inputs.outputs.CI_CARGO_PROFILE }}

container:
needs: rust
uses: ./.github/workflows/container.yaml
32 changes: 32 additions & 0 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Containers
on:
workflow_call:
inputs:
additional-tags:
type: string

# See https://stackoverflow.com/questions/66335225/how-to-cancel-previous-runs-in-the-pr-when-you-push-new-commitsupdate-the-curre
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build Container
runs-on: ubuntu-24.04
steps:
- uses: actions/[email protected]
- name: Download Rust Artifacts
uses: actions/[email protected]
with:
name: rust
path: artifacts
- name: Build Image
id: build-image
uses: redhat-actions/[email protected]
with:
image: identity-server
tags: ${{ github.sha }} ${{ inputs.additional-tags }}
containerfiles: |
./identity-server/Dockerfile
102 changes: 0 additions & 102 deletions .github/workflows/release.yaml

This file was deleted.

Loading

0 comments on commit 53a1edb

Please sign in to comment.