Skip to content

Commit 64895fa

Browse files
feat: Overhaul CI testing. (#192)
This commit does a few things: - Restructures CI testing files to split out conventional commits checking into its own file. - Updates cargo-dist to the latest version. - Updates CI testing to be run on a matrix of MacOS, Ubuntu, and Windows. There's more to do in the future, including making sure our test matrix matches the host types used for building release artifacts for the CLI, but this is a good start. Signed-off-by: Andrew Lilley Brinker <alilleybrinker@gmail.com>
1 parent f7ab3fd commit 64895fa

File tree

10 files changed

+179
-132
lines changed

10 files changed

+179
-132
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/commits.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Commit Checks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
conventional-commits:
12+
name: Conventional Commits
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: webiny/action-conventional-commits@v1.3.0

.github/workflows/release.yml

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This file was autogenerated by cargo-dist: https://opensource.axo.dev/cargo-dist/
2+
#
13
# Copyright 2022-2024, axodotdev
24
# SPDX-License-Identifier: MIT or Apache-2.0
35
#
@@ -12,11 +14,10 @@
1214
# title/body based on your changelogs.
1315

1416
name: Release
15-
1617
permissions:
17-
contents: write
18-
id-token: write
19-
attestations: write
18+
"attestations": "write"
19+
"contents": "write"
20+
"id-token": "write"
2021

2122
# This task will run whenever you push a git tag that looks like a version
2223
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -64,7 +65,12 @@ jobs:
6465
# we specify bash to get pipefail; it guards against the `curl` command
6566
# failing. otherwise `sh` won't catch that `curl` returned non-0
6667
shell: bash
67-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
68+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.21.1/cargo-dist-installer.sh | sh"
69+
- name: Cache cargo-dist
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: cargo-dist-cache
73+
path: ~/.cargo/bin/cargo-dist
6874
# sure would be cool if github gave us proper conditionals...
6975
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7076
# functionality based on whether this is a pull_request, and whether it's from a fork.
@@ -113,10 +119,6 @@ jobs:
113119
- uses: actions/checkout@v4
114120
with:
115121
submodules: recursive
116-
- uses: swatinem/rust-cache@v2
117-
with:
118-
key: ${{ join(matrix.targets, '-') }}
119-
cache-provider: ${{ matrix.cache_provider }}
120122
- name: Install cargo-dist
121123
run: ${{ matrix.install_dist }}
122124
# Get the dist-manifest
@@ -172,9 +174,12 @@ jobs:
172174
- uses: actions/checkout@v4
173175
with:
174176
submodules: recursive
175-
- name: Install cargo-dist
176-
shell: bash
177-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
177+
- name: Install cached cargo-dist
178+
uses: actions/download-artifact@v4
179+
with:
180+
name: cargo-dist-cache
181+
path: ~/.cargo/bin/
182+
- run: chmod +x ~/.cargo/bin/cargo-dist
178183
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
179184
- name: Fetch local artifacts
180185
uses: actions/download-artifact@v4
@@ -218,16 +223,19 @@ jobs:
218223
- uses: actions/checkout@v4
219224
with:
220225
submodules: recursive
221-
- name: Install cargo-dist
222-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.16.0/cargo-dist-installer.sh | sh"
226+
- name: Install cached cargo-dist
227+
uses: actions/download-artifact@v4
228+
with:
229+
name: cargo-dist-cache
230+
path: ~/.cargo/bin/
231+
- run: chmod +x ~/.cargo/bin/cargo-dist
223232
# Fetch artifacts from scratch-storage
224233
- name: Fetch artifacts
225234
uses: actions/download-artifact@v4
226235
with:
227236
pattern: artifacts-*
228237
path: target/distrib/
229238
merge-multiple: true
230-
# This is a harmless no-op for GitHub Releases, hosting for that happens in "announce"
231239
- id: host
232240
shell: bash
233241
run: |
@@ -241,23 +249,7 @@ jobs:
241249
# Overwrite the previous copy
242250
name: artifacts-dist-manifest
243251
path: dist-manifest.json
244-
245-
# Create a GitHub Release while uploading all files to it
246-
announce:
247-
needs:
248-
- plan
249-
- host
250-
# use "always() && ..." to allow us to wait for all publish jobs while
251-
# still allowing individual publish jobs to skip themselves (for prereleases).
252-
# "host" however must run to completion, no skipping allowed!
253-
if: ${{ always() && needs.host.result == 'success' }}
254-
runs-on: "ubuntu-20.04"
255-
env:
256-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
257-
steps:
258-
- uses: actions/checkout@v4
259-
with:
260-
submodules: recursive
252+
# Create a GitHub Release while uploading all files to it
261253
- name: "Download GitHub Artifacts"
262254
uses: actions/download-artifact@v4
263255
with:
@@ -270,12 +262,28 @@ jobs:
270262
rm -f artifacts/*-dist-manifest.json
271263
- name: Create GitHub Release
272264
env:
273-
PRERELEASE_FLAG: "${{ fromJson(needs.host.outputs.val).announcement_is_prerelease && '--prerelease' || '' }}"
274-
ANNOUNCEMENT_TITLE: "${{ fromJson(needs.host.outputs.val).announcement_title }}"
275-
ANNOUNCEMENT_BODY: "${{ fromJson(needs.host.outputs.val).announcement_github_body }}"
265+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
266+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
267+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
268+
RELEASE_COMMIT: "${{ github.sha }}"
276269
run: |
277270
# Write and read notes from a file to avoid quoting breaking things
278271
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
279272
280-
gh release create "${{ needs.plan.outputs.tag }}" --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" $PRERELEASE_FLAG
281-
gh release upload "${{ needs.plan.outputs.tag }}" artifacts/*
273+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
274+
275+
announce:
276+
needs:
277+
- plan
278+
- host
279+
# use "always() && ..." to allow us to wait for all publish jobs while
280+
# still allowing individual publish jobs to skip themselves (for prereleases).
281+
# "host" however must run to completion, no skipping allowed!
282+
if: ${{ always() && needs.host.result == 'success' }}
283+
runs-on: "ubuntu-20.04"
284+
env:
285+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
286+
steps:
287+
- uses: actions/checkout@v4
288+
with:
289+
submodules: recursive

.github/workflows/test.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Test
2+
3+
# Run on both PRs and pushes to the main branch.
4+
# It may seem redundant to run tests on main, since we disallow pushing directly
5+
# to main and all PRs get tested before merging.
6+
#
7+
# But due to how GitHub Actions isolates caches, we need to run the tests on
8+
# main so that caches are available to new PRs. The caches created when testing
9+
# PR code cannot be re-used outside of testing that PR.
10+
#
11+
# See the GitHub Actions documentation here:
12+
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
13+
on:
14+
push:
15+
branches: [main]
16+
paths:
17+
- "gitoid/**"
18+
- "omnibor/**"
19+
- "omnibor-cli/**"
20+
- "xtask/**"
21+
pull_request:
22+
branches: [main]
23+
paths:
24+
- "gitoid/**"
25+
- "omnibor/**"
26+
- "omnibor-cli/**"
27+
- "xtask/**"
28+
29+
permissions:
30+
contents: read
31+
32+
env:
33+
RUSTFLAGS: -Dwarnings
34+
CARGO_TERM_COLOR: always
35+
36+
jobs:
37+
test:
38+
strategy:
39+
matrix:
40+
os: [ubuntu-latest, windows-latest, macos-latest]
41+
name: "${{ matrix.os }}"
42+
runs-on: ${{ matrix.os }}
43+
timeout-minutes: 15
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: dtolnay/rust-toolchain@stable
47+
- uses: swatinem/rust-cache@v2
48+
with:
49+
key: ${{ matrix.os }}
50+
- name: Dependency Tree
51+
run: cargo tree
52+
- name: Check
53+
run: cargo check --verbose --workspace
54+
- name: Test
55+
run: cargo test --verbose --workspace
56+
- name: Lint
57+
run: cargo clippy --verbose --workspace

Cargo.toml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,21 @@ homepage = "https://omnibor.io"
1616
# Config for 'cargo dist'
1717
[workspace.metadata.dist]
1818
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
19-
cargo-dist-version = "0.16.0"
19+
cargo-dist-version = "0.21.1"
2020
# CI backends to support
2121
ci = "github"
2222
# The installers to generate for each app
2323
installers = ["shell", "powershell"]
2424
# Target platforms to build apps for (Rust target-triple syntax)
25-
targets = [
26-
"aarch64-apple-darwin",
27-
"x86_64-apple-darwin",
28-
"x86_64-unknown-linux-gnu",
29-
"x86_64-unknown-linux-musl",
30-
"x86_64-pc-windows-msvc",
31-
]
32-
# Publish jobs to run in CI
25+
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]
26+
# Which actions to run on pull requests
3327
pr-run-mode = "plan"
3428
# Whether to install an updater program
3529
install-updater = false
3630
# Whether to enable GitHub Attestations
3731
github-attestations = true
32+
# Path that installers should place binaries in
33+
install-path = "CARGO_HOME"
3834

3935
# The profile that 'cargo dist' will build with
4036
[profile.dist]

gitoid/benches/benchmark.rs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ use criterion::black_box;
22
use criterion::criterion_group;
33
use criterion::criterion_main;
44
use criterion::Criterion;
5-
#[cfg(all(feature = "rustcrypto", feature = "sha1"))]
6-
use gitoid::rustcrypto::Sha1 as RustSha1;
7-
#[cfg(all(feature = "rustcrypto", feature = "sha256"))]
8-
use gitoid::rustcrypto::Sha256 as RustSha256;
9-
use gitoid::Blob;
105
#[cfg(all(feature = "boringssl", feature = "sha1"))]
116
use gitoid::boringssl::Sha1 as BoringSha1;
127
#[cfg(all(feature = "boringssl", feature = "sha256"))]
138
use gitoid::boringssl::Sha256 as BoringSha256;
14-
use gitoid::GitOid;
15-
#[cfg(all(feature = "openssl", feature = "sha1"))]
16-
use gitoid::openssl::Sha256 as OpenSSLSha256;
179
#[cfg(all(feature = "openssl", feature = "sha1"))]
1810
use gitoid::openssl::Sha1 as OpenSSLSha1;
11+
#[cfg(all(feature = "openssl", feature = "sha1"))]
12+
use gitoid::openssl::Sha256 as OpenSSLSha256;
13+
#[cfg(all(feature = "rustcrypto", feature = "sha1"))]
14+
use gitoid::rustcrypto::Sha1 as RustSha1;
15+
#[cfg(all(feature = "rustcrypto", feature = "sha256"))]
16+
use gitoid::rustcrypto::Sha256 as RustSha256;
17+
use gitoid::Blob;
18+
use gitoid::GitOid;
1919

2020
#[cfg(not(any(feature = "rustcrypto", feature = "boringssl",)))]
2121
compile_error!(
@@ -187,20 +187,44 @@ criterion_group!(
187187
#[cfg(all(feature = "rustcrypto", feature = "boringssl", feature = "openssl"))]
188188
criterion_main!(rustcrypto_benches, boringssl_benches, openssl_benches);
189189

190-
#[cfg(all(feature = "rustcrypto", feature = "boringssl", not(feature= "openssl")))]
190+
#[cfg(all(
191+
feature = "rustcrypto",
192+
feature = "boringssl",
193+
not(feature = "openssl")
194+
))]
191195
criterion_main!(rustcrypto_benches, boringssl_benches);
192196

193-
#[cfg(all(not(feature = "rustcrypto"), feature = "boringssl", feature= "openssl"))]
197+
#[cfg(all(
198+
not(feature = "rustcrypto"),
199+
feature = "boringssl",
200+
feature = "openssl"
201+
))]
194202
criterion_main!(boringssl_benches, openssl_benches());
195203

196-
#[cfg(all(feature = "rustcrypto", not(feature = "boringssl"), feature= "openssl"))]
204+
#[cfg(all(
205+
feature = "rustcrypto",
206+
not(feature = "boringssl"),
207+
feature = "openssl"
208+
))]
197209
criterion_main!(rustcrypto_benches, openssl_benches);
198210

199-
#[cfg(all(feature = "rustcrypto", not(feature = "boringssl"), not(feature= "openssl")))]
211+
#[cfg(all(
212+
feature = "rustcrypto",
213+
not(feature = "boringssl"),
214+
not(feature = "openssl")
215+
))]
200216
criterion_main!(rustcrypto_benches);
201217

202-
#[cfg(all(not(feature = "rustcrypto"), feature = "boringssl", not(feature = "openssl")))]
218+
#[cfg(all(
219+
not(feature = "rustcrypto"),
220+
feature = "boringssl",
221+
not(feature = "openssl")
222+
))]
203223
criterion_main!(boringssl_benches);
204224

205-
#[cfg(all(not(feature = "rustcrypto"), not(feature = "boringssl"), feature = "openssl"))]
225+
#[cfg(all(
226+
not(feature = "rustcrypto"),
227+
not(feature = "boringssl"),
228+
feature = "openssl"
229+
))]
206230
criterion_main!(openssl_benches);

gitoid/src/backend/openssl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::impl_hash_algorithm;
44
use crate::sealed::Sealed;
55
use crate::HashAlgorithm;
6-
use openssl::sha;
76
use digest::consts::U20;
87
use digest::consts::U32;
98
use digest::generic_array::GenericArray;
@@ -13,6 +12,7 @@ use digest::HashMarker;
1312
use digest::Output;
1413
use digest::OutputSizeUser;
1514
use digest::Update;
15+
use openssl::sha;
1616

1717
#[cfg(feature = "sha1")]
1818
/// SHA-1 algorithm

0 commit comments

Comments
 (0)