Skip to content

Commit 1fa9f41

Browse files
committed
Add workflow to run tests and build checks
Signed-off-by: Keshav Priyadarshi <[email protected]>
1 parent 7db9632 commit 1fa9f41

File tree

3 files changed

+72
-3
lines changed

3 files changed

+72
-3
lines changed

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Rust CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
build-test:
12+
name: Run test and build
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
target: x86_64-unknown-linux-gnu
19+
20+
- os: ubuntu-24.04-arm
21+
target: aarch64-unknown-linux-gnu
22+
23+
- os: macos-14
24+
target: aarch64-apple-darwin
25+
26+
- os: macos-15
27+
target: aarch64-apple-darwin
28+
29+
- os: macos-15-intel
30+
target: x86_64-apple-darwin
31+
32+
- os: windows-latest
33+
target: x86_64-pc-windows-msvc
34+
35+
runs-on: ${{ matrix.os }}
36+
37+
steps:
38+
- name: Checkout source
39+
uses: actions/checkout@v4
40+
41+
- name: Install Rust
42+
uses: dtolnay/rust-toolchain@stable
43+
with:
44+
components: rustfmt, clippy
45+
46+
- name: Check fmt and linting
47+
run: make check
48+
49+
- name: Run tests
50+
run: cargo test --target ${{ matrix.target }} --verbose
51+
52+
- name: Build
53+
run: cargo build --target ${{ matrix.target }} --verbose

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
build-fst:
22
cargo run --bin fst_builder
33

4-
54
clean:
65
cargo clean
76
rm -f purls.fst
87
rm -rf target
98

10-
.PHONY: build-fst clean
9+
test:
10+
cargo test
11+
12+
valid:
13+
cargo fmt --all
14+
cargo clippy --all-targets --all-features
15+
16+
check:
17+
cargo fmt --all -- --check
18+
cargo clippy --all-targets --all-features -- -D warnings
19+
20+
.PHONY: build-fst clean test valid check

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg?style=for-the-badge)](https://opensource.org/licenses/Apache-2.0)
44
[![Version](https://img.shields.io/github/v/release/aboutcode-org/purl-validator-rust?style=for-the-badge)](https://github.com/aboutcode-org/purl-validator-rust/releases)
5-
[![Test](https://img.shields.io/github/actions/workflow/status/aboutcode-org/purl-validator-rust/run-test.yml?style=for-the-badge&logo=github)](https://github.com/aboutcode-org/purl-validator-rust/actions)
5+
[![Test](https://img.shields.io/github/actions/workflow/status/aboutcode-org/purl-validator-rust/ci.yml?style=for-the-badge&logo=github)](https://github.com/aboutcode-org/purl-validator-rust/actions)
66

77
**purl-validator** is a Rust library for validating [Package URLs (PURLs)](https://github.com/package-url/purl-spec). It works fully offline, including in **air-gapped** or **restricted environments**, and answers one key question: **Does the package this PURL represents actually exist?**
88

@@ -53,6 +53,12 @@ Run tests:
5353
make test
5454
```
5555

56+
Fix formatting and linting:
57+
58+
```bash
59+
make valid
60+
```
61+
5662
## License
5763

5864
SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)