-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflows to test, build containers and binaries
- Loading branch information
Showing
4 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Build and upload Docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*.*.*" | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
|
||
env: | ||
REGISTRY: ghcr.io/${{ github.repository_owner }} | ||
|
||
jobs: | ||
builds-linux: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
target: [subfile-exchange] | ||
|
||
permissions: | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
${{ env.REGISTRY }}/${{matrix.target}} | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}}.{{minor}}.{{patch}} | ||
type=semver,pattern={{major}} | ||
type=sha | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./ | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
file: Dockerfile.${{ matrix.target }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build and upload release binaries | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-linux: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- name: Build release binary | ||
run: | | ||
cargo build --release | ||
- name: Upload Ubuntu binary | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./target/release/subfile-exchange | ||
asset_name: subfile-exchange-${{ github.event.release.tag_name }}-ubuntu | ||
asset_content_type: binary/octet-stream | ||
build-macos: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
- name: Build release binary | ||
run: | | ||
cargo build --release | ||
- name: Upload MacOS binary | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./target/release/subfile-exchange | ||
asset_name: subfile-exchange-${{ github.event.release.tag_name }}-macos | ||
asset_content_type: binary/octet-stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: tests | ||
|
||
on: | ||
push: | ||
branches: [ main, dev ] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
fmt: | ||
name: cargo fmt | ||
runs-on: ubuntu-latest | ||
container: | ||
image: rust:1.74-bookworm | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: | | ||
rustup component add rustfmt | ||
cargo fmt --all -- --check | ||
clippy: | ||
name: cargo clippy | ||
runs-on: ubuntu-latest | ||
container: | ||
image: rust:1.74-bookworm | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }} | ||
- run: | | ||
rustup component add clippy | ||
# Temporarily allowing dead-code, while denying all other warnings | ||
cargo clippy --all-features --all-targets -- -A dead-code -D warnings | ||
test-and-coverage: | ||
name: cargo test and coverage | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
actions: read | ||
container: | ||
image: rust:1.74-bookworm | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
- name: Run tests and generate coverage report | ||
run: cargo llvm-cov test --all-features --workspace --lcov --output-path lcov.info | ||
- name: Test documentation code snippets | ||
run: cargo test --doc --all-features --workspace | ||
- name: Upload coverage to Coveralls | ||
uses: coverallsapp/[email protected] | ||
with: | ||
file: ./lcov.info |