Skip to content

Commit 7cdb864

Browse files
committed
chore: improve CI
* improve CI workflow: * add automatic dependabot updates (crates and actions) * move all project-specific CI logic into the `justfile` - this allows developers to re-run the same steps as CI locally, without the need to replicate whatever is being done in the CI * add test, test-msrv, coverage, and the release jobs * the release job will not actually release until crate version changes. See [docs](https://release-plz.dev/docs). It runs on all merges to main branch, and auto-generates a "release PR" - suggesting version bump and changelog file changes. * Added pre-commit CI -- once enabled, this will keep all PRs clean by automatically doing `cargo fmt` and other minor linting, without requiring users to re-submit their changes. * deleted and git-ignored the Lock file - libs should not have this file checked in, as it prevents maintainers from seeeing build bugs that the end users will encounter.
1 parent d47a254 commit 7cdb864

File tree

10 files changed

+374
-179
lines changed

10 files changed

+374
-179
lines changed

.github/dependabot.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 2
2+
updates:
3+
4+
# Maintain dependencies for GitHub Actions
5+
- package-ecosystem: github-actions
6+
directory: "/"
7+
schedule:
8+
interval: weekly
9+
groups:
10+
all-actions-version-updates:
11+
applies-to: version-updates
12+
patterns:
13+
- "*"
14+
all-actions-security-updates:
15+
applies-to: security-updates
16+
patterns:
17+
- "*"
18+
19+
# Update Rust dependencies
20+
- package-ecosystem: cargo
21+
directory: "/"
22+
schedule:
23+
interval: daily
24+
time: "02:00"
25+
open-pull-requests-limit: 10
26+
groups:
27+
all-cargo-version-updates:
28+
applies-to: version-updates
29+
patterns:
30+
- "*"
31+
all-cargo-security-updates:
32+
applies-to: security-updates
33+
patterns:
34+
- "*"

.github/workflows/ci.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
release:
9+
types: [ published ]
10+
workflow_dispatch:
11+
12+
defaults:
13+
run:
14+
shell: bash
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
test:
21+
name: Test
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
matrix:
25+
os: [ ubuntu-latest, macos-15 ]
26+
steps:
27+
- uses: actions/checkout@v4
28+
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
29+
uses: Swatinem/rust-cache@v2
30+
- uses: dtolnay/rust-toolchain@stable
31+
- uses: taiki-e/install-action@v2
32+
with: { tool: just }
33+
- run: just ci-test
34+
35+
test-msrv:
36+
name: Test MSRV
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
matrix:
40+
os: [ ubuntu-latest, macos-15 ]
41+
steps:
42+
- uses: actions/checkout@v4
43+
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
44+
uses: Swatinem/rust-cache@v2
45+
- uses: taiki-e/install-action@v2
46+
with: { tool: just }
47+
- name: Read MSRV
48+
id: msrv
49+
run: echo "value=$(just get-msrv)" >> $GITHUB_OUTPUT
50+
- name: Install MSRV Rust ${{ steps.msrv.outputs.value }}
51+
uses: dtolnay/rust-toolchain@stable
52+
with:
53+
toolchain: ${{ steps.msrv.outputs.value }}
54+
- run: just ci_mode=0 ci-test-msrv # Ignore warnings in MSRV
55+
56+
coverage:
57+
name: Code Coverage
58+
if: github.event_name != 'release'
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
- uses: Swatinem/rust-cache@v2
63+
- uses: taiki-e/install-action@v2
64+
with: { tool: 'just,cargo-llvm-cov' }
65+
- name: Generate code coverage
66+
run: just ci-coverage
67+
- name: Upload coverage to Codecov
68+
uses: codecov/codecov-action@v5
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}
71+
files: target/llvm-cov/codecov.info
72+
fail_ci_if_error: false
73+
74+
# This job checks if any of the previous jobs failed or were canceled.
75+
# This approach also allows some jobs to be skipped if they are not needed.
76+
ci-passed:
77+
needs: [ test, test-msrv ]
78+
if: always()
79+
runs-on: ubuntu-latest
80+
steps:
81+
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
82+
run: exit 1
83+
84+
# Release unpublished packages or create a PR with changes
85+
release-plz:
86+
needs: [ ci-passed ]
87+
if: |
88+
always()
89+
&& needs.ci-passed.result == 'success'
90+
&& github.event_name == 'push'
91+
&& github.ref == 'refs/heads/main'
92+
&& github.repository_owner == 'harfbuzz'
93+
runs-on: ubuntu-latest
94+
permissions:
95+
contents: write
96+
pull-requests: write
97+
concurrency:
98+
group: release-plz-${{ github.ref }}
99+
cancel-in-progress: false
100+
steps:
101+
- uses: actions/checkout@v4
102+
with: { fetch-depth: 0 }
103+
- uses: dtolnay/rust-toolchain@stable
104+
- name: Publish to crates.io if crate's version is newer
105+
uses: release-plz/[email protected]
106+
id: release
107+
with: { command: release }
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
110+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
111+
- name: If version is the same, create a PR proposing new version and changelog for the next release
112+
uses: release-plz/[email protected]
113+
if: ${{ steps.release.outputs.releases_created == 'false' }}
114+
with: { command: release-pr }
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}

.github/workflows/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
jobs:
5+
dependabot:
6+
runs-on: ubuntu-latest
7+
if: github.actor == 'dependabot[bot]'
8+
steps:
9+
- name: Dependabot metadata
10+
id: metadata
11+
uses: dependabot/fetch-metadata@v2
12+
- name: Approve Dependabot PRs
13+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
14+
run: gh pr review --approve "$PR_URL"
15+
env:
16+
PR_URL: ${{ github.event.pull_request.html_url }}
17+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
18+
- name: Enable auto-merge for Dependabot PRs
19+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
20+
run: gh pr merge --auto --squash "$PR_URL"
21+
env:
22+
PR_URL: ${{ github.event.pull_request.html_url }}
23+
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}

.github/workflows/main.yml

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.DS_Store
55
/src/complex/*.ri
66
.vscode
7+
Cargo.lock

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-executables-have-shebangs
9+
- id: check-json
10+
- id: check-shebang-scripts-are-executable
11+
exclude: '.+\.rs' # would be triggered by #![some_attribute]
12+
- id: check-symlinks
13+
- id: check-toml
14+
- id: check-yaml
15+
args: [ --allow-multiple-documents ]
16+
- id: destroyed-symlinks
17+
- id: end-of-file-fixer
18+
- id: mixed-line-ending
19+
args: [ --fix=lf ]
20+
- id: trailing-whitespace
21+
22+
- repo: https://github.com/Lucas-C/pre-commit-hooks
23+
rev: v1.5.5
24+
hooks:
25+
- id: forbid-tabs
26+
- id: remove-tabs
27+
28+
- repo: local
29+
hooks:
30+
- id: cargo-fmt
31+
name: Rust Format
32+
description: "Automatically format Rust code with cargo fmt"
33+
entry: sh -c "cargo fmt --all"
34+
language: rust
35+
pass_filenames: false

Cargo.lock

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

0 commit comments

Comments
 (0)