Skip to content

Commit e500736

Browse files
ci: implement basic CI pipeline
includes: - commit linting - source code linting - cargo test - semantic release - publish to crates.io (dry run)
1 parent 0cf4ee9 commit e500736

10 files changed

+234
-0
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Feo Tensor CI
2+
3+
on:
4+
pull_request: {}
5+
push:
6+
branches: [ main ]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
lint:
14+
name: Lint
15+
uses: "./.github/workflows/lint.yml"
16+
17+
test:
18+
name: Test
19+
uses: "./.github/workflows/test.yml"
20+
21+
release:
22+
name: Release
23+
needs:
24+
- lint
25+
- test
26+
uses: "./.github/workflows/release.yml"
27+
28+
publish:
29+
name: Publish
30+
needs: release
31+
uses: "./.github/workflows/publish.yml"
32+
with:
33+
new_release_published: ${{ needs.release.outputs.new_release_published }}
34+
new_release_version: ${{ needs.release.outputs.new_release_version }}

.github/workflows/lint.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Lint
2+
3+
on:
4+
workflow_call: {}
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
lint-rust:
11+
name: Rust Lint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Rust
18+
uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: rustfmt, clippy
21+
22+
- name: Rust Format
23+
run: cargo fmt --all -- --check
24+
25+
- name: Clippy
26+
run: cargo clippy --all --all-features -- -D warnings
27+
28+
lint-commits:
29+
name: Commit Lint
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- uses: actions/setup-node@v4
38+
with:
39+
node-version: 20
40+
41+
- name: Install commitlint
42+
run: npm install --save-dev @commitlint/{cli,config-conventional}
43+
44+
- name: Commitlint (PR)
45+
if: github.event_name == 'pull_request'
46+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }}
47+
48+
- name: Commitlint (Push)
49+
if: github.event_name == 'push'
50+
run: npx commitlint --from ${{ github.event.before }}

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
new_release_published:
7+
required: true
8+
type: string
9+
new_release_version:
10+
required: true
11+
type: string
12+
13+
jobs:
14+
publish-crate:
15+
name: Publish Crate
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Setup Rust
22+
uses: dtolnay/rust-toolchain@stable
23+
24+
- name: Bump Version
25+
if: ${{ github.event.inputs.new_release_published == 'true' }}
26+
run: |
27+
cargo install cargo-bump
28+
cargo bump ${{ github.event.inputs.new_release_version }}
29+
30+
- name: Publish Crate (dry run)
31+
run: cargo publish --dry-run
32+
33+
- name: Publish Crate
34+
if: ${{ github.event.inputs.new_release_published == 'true' }}
35+
run: cargo publish --dry-run # Until we actually want to publish we'll keep this as is

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
new_release_published:
7+
value: ${{ jobs.release.outputs.new_release_published }}
8+
new_release_version:
9+
value: ${{ jobs.release.outputs.new_release_version }}
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
issues: write
15+
16+
jobs:
17+
release:
18+
name: Release
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Semantic Release
27+
id: semantic-release
28+
uses: cycjimmy/semantic-release-action@v4
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
outputs:
33+
new_release_published: ${{ steps.semantic-release.outputs.new_release_published }}
34+
new_release_version: ${{ steps.semantic-release.outputs.new_release_version }}

.github/workflows/test.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test
2+
3+
on:
4+
workflow_call: {}
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
test-rust:
11+
name: Rust Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Rust
18+
uses: dtolnay/rust-toolchain@stable
19+
20+
- name: Rust Test
21+
run: cargo test --all-features

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributing to feotensor
2+
3+
## Commit Convention
4+
5+
`feotensor` infrastructure enforces [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/).
6+
A `commitlint` CI check ensures that commits to `main` are all of this format. We use these commits
7+
to automatically generate a release number according to compatible versioning (ComVer).
8+
9+
ComVer allows only major or minor version bumps (no patch). A major version bump is not backwards
10+
compatible. A minor version bump is backwards compatible.
11+
12+
Major version bumps are achieved either by adding a `!` immediately before the `:`, or by adding
13+
`BREAKING CHANGE` to the commit footer.
14+
15+
Otherwise all other commits result either in no release, or in a minor bump. For details on exactly
16+
which commit types can trigger a release, and which commit types cannot, see `release.config.js`.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
name = "feotensor"
33
version = "0.1.0"
44
edition = "2021"
5+
description = "A Scientific Rust library for tensor operations"
6+
license = "MIT"
7+
license-file = "LICENSE"
8+
homepage = "https://github.com/Rust-Scientific-Computing/feotensor"
9+
repository = "https://github.com/Rust-Scientific-Computing/feotensor"
510

611
[dependencies]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# feotensor
22

3+
[![Feo Tensor CI](https://github.com/Rust-Scientific-Computing/feotensor/actions/workflows/ci.yml/badge.svg)](https://github.com/Rust-Scientific-Computing/feotensor/actions/workflows/ci.yml)
4+
35
A tensor library for scientific computing in Rust.

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ["@commitlint/config-conventional"]
3+
};

release.config.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = {
2+
branches: ["main"],
3+
plugins: [
4+
[
5+
"@semantic-release/commit-analyzer",
6+
{
7+
preset: "angular",
8+
releaseRules: [
9+
{ type: "build", release: "minor" },
10+
{ type: "chore", release: "minor" },
11+
{ type: "ci", release: false },
12+
{ type: "docs", release: false },
13+
{ type: "feat", release: "minor" },
14+
{ type: "fix", release: "minor" },
15+
{ type: "perf", release: "minor" },
16+
{ type: "refactor", release: false },
17+
{ type: "revert", release: "minor" },
18+
{ type: "style", release: false },
19+
{ type: "test", release: false },
20+
]
21+
}
22+
],
23+
"@semantic-release/release-notes-generator",
24+
"@semantic-release/changelog",
25+
[
26+
"@semantic-release/github",
27+
{
28+
successComment: false,
29+
failComment: false,
30+
failTitle: false
31+
}
32+
]
33+
]
34+
};

0 commit comments

Comments
 (0)