Skip to content

Commit 5048967

Browse files
committed
yonasBSD improvements.
1 parent dc23de8 commit 5048967

File tree

13 files changed

+255
-37
lines changed

13 files changed

+255
-37
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[alias]
2+
xtask = "run --package xtask --"

.github/workflows/coverage.yaml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
on:
2+
pull_request:
3+
push:
4+
branches:
5+
- main
6+
7+
name: Coverage
8+
9+
jobs:
10+
check:
11+
name: Check
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout sources
15+
uses: actions/checkout@v2
16+
17+
- name: Install stable toolchain
18+
uses: actions-rs/toolchain@v1
19+
with:
20+
profile: minimal
21+
toolchain: stable
22+
override: true
23+
24+
- uses: Swatinem/rust-cache@v1
25+
26+
- name: Run cargo check
27+
uses: actions-rs/cargo@v1
28+
with:
29+
command: check
30+
31+
test:
32+
name: Test Suite
33+
strategy:
34+
matrix:
35+
os: [ubuntu-latest, macos-latest, windows-latest]
36+
rust: [stable]
37+
runs-on: ${{ matrix.os }}
38+
steps:
39+
- name: Checkout sources
40+
uses: actions/checkout@v4
41+
42+
- name: Install stable toolchain
43+
uses: actions-rs/toolchain@v1
44+
with:
45+
profile: minimal
46+
toolchain: ${{ matrix.rust }}
47+
override: true
48+
49+
- uses: Swatinem/rust-cache@v1
50+
51+
- name: Run cargo test
52+
uses: actions-rs/cargo@v1
53+
with:
54+
command: test
55+
56+
coverage:
57+
name: Coverage
58+
strategy:
59+
matrix:
60+
os: [ubuntu-latest]
61+
rust: [stable,nightly]
62+
runs-on: ${{ matrix.os }}
63+
steps:
64+
- name: Checkout sources
65+
uses: actions/checkout@v4
66+
67+
- name: Install stable toolchain
68+
uses: actions-rs/toolchain@v1
69+
with:
70+
toolchain: ${{ matrix.rust }}
71+
override: true
72+
components: llvm-tools-preview
73+
74+
- uses: Swatinem/rust-cache@v1
75+
76+
- name: Download grcov
77+
run: |
78+
mkdir -p "${HOME}/.local/bin"
79+
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
80+
echo "$HOME/.local/bin" >> $GITHUB_PATH
81+
82+
- name: Run xtask coverage
83+
uses: actions-rs/cargo@v1
84+
with:
85+
command: xtask
86+
args: coverage
87+
88+
# - name: Upload to codecov.io
89+
# uses: codecov/codecov-action@v4
90+
# with:
91+
# files: coverage/*.lcov
92+
93+
lints:
94+
name: Lints
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout sources
98+
uses: actions/checkout@v4
99+
with:
100+
submodules: true
101+
102+
- name: Install stable toolchain
103+
uses: actions-rs/toolchain@v1
104+
with:
105+
profile: minimal
106+
toolchain: stable
107+
override: true
108+
components: rustfmt, clippy
109+
110+
- uses: Swatinem/rust-cache@v1
111+
112+
- name: Run cargo fmt
113+
uses: actions-rs/cargo@v1
114+
with:
115+
command: fmt
116+
args: --all -- --check
117+
118+
- name: Run cargo clippy
119+
uses: actions-rs/cargo@v1
120+
with:
121+
command: clippy
122+
args: -- -D warnings

.github/workflows/check-and-lint.yaml renamed to .github/workflows/lint.yaml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,65 @@ on:
55
- main
66

77

8-
name: Check and Lint
8+
name: Linting
99

1010
jobs:
1111
check:
1212
name: Check
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions-rs/toolchain@v1
15+
- uses: actions/checkout@v4
16+
17+
- uses: dtolnay/rust-toolchain@stable
1718
with:
1819
profile: minimal
1920
toolchain: stable
2021
override: true
22+
2123
- uses: actions-rs/cargo@v1
2224
with:
2325
command: check
2426

2527
fmt:
26-
name: Rustfmt
28+
name: Rustfmt and treefmt
2729
runs-on: ubuntu-latest
2830
steps:
29-
- uses: actions/checkout@v2
30-
- uses: actions-rs/toolchain@v1
31+
- uses: actions/checkout@v4
32+
33+
- uses: dtolnay/rust-toolchain@stable
3134
with:
3235
profile: minimal
3336
toolchain: stable
3437
override: true
3538
- run: rustup component add rustfmt
39+
3640
- uses: actions-rs/cargo@v1
3741
with:
3842
command: fmt
3943
args: --all -- --check
4044

45+
- name: treefmt
46+
run: |
47+
sudo apt install gojq
48+
curl -s https://api.github.com/repos/numtide/treefmt/tags | gojq -r '.[0].name' > .ver
49+
curl -sSLo treefmt.tgz https://github.com/numtide/treefmt/releases/download/$(cat .ver)/treefmt_$(cat .ver | cut -d'v' -f2)_linux_amd64.tar.gz
50+
tar -xvf treefmt.tgz
51+
./treefmt
52+
4153
clippy:
4254
name: Clippy
4355
runs-on: ubuntu-latest
4456
steps:
45-
- uses: actions/checkout@v2
46-
- uses: actions-rs/toolchain@v1
57+
- uses: actions/checkout@v4
58+
59+
- uses: dtolnay/rust-toolchain@stable
4760
with:
4861
toolchain: stable
4962
components: clippy
5063
override: true
64+
5165
- uses: actions-rs/clippy-check@v1
5266
with:
5367
token: ${{ secrets.GITHUB_TOKEN }}
5468
args: --all-features
55-
name: Clippy Output
69+
name: Clippy Output

.github/workflows/release-packaging.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ jobs:
99
release:
1010
name: Release Packaging
1111
env:
12-
PROJECT_NAME_UNDERSCORE: rust_ci_github_actions_workflow
12+
PROJECT_NAME_UNDERSCORE: test2
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions-rs/toolchain@v1
15+
- uses: actions/checkout@v4
16+
- uses: dtolnay/rust-toolchain@stable
1717
with:
1818
profile: minimal
1919
toolchain: stable
2020
override: true
2121
- name: Release Build
2222
run: cargo build --release
2323
- name: 'Upload Artifact'
24-
uses: actions/upload-artifact@v2
24+
uses: actions/upload-artifact@v4
2525
with:
2626
name: ${{ env.PROJECT_NAME_UNDERSCORE }}
2727
path: target/release/${{ env.PROJECT_NAME_UNDERSCORE }}

.github/workflows/test.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ jobs:
1010
test:
1111
name: Test
1212
env:
13-
PROJECT_NAME_UNDERSCORE: rust_ci_github_actions_workflow
13+
PROJECT_NAME_UNDERSCORE: test2
1414
CARGO_INCREMENTAL: 0
1515
RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
1616
RUSTDOCFLAGS: -Cpanic=abort
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v3
20-
- uses: actions-rs/toolchain@v1
19+
- uses: actions/checkout@v4
20+
- uses: dtolnay/rust-toolchain@stable
2121
with:
2222
profile: minimal
2323
toolchain: nightly
@@ -35,9 +35,18 @@ jobs:
3535
~/.cargo/registry/cache
3636
target
3737
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
38+
39+
- name: Download grcov
40+
run: |
41+
sudo apt install gojq
42+
mkdir -p "${HOME}/.local/bin"
43+
curl -s https://api.github.com/repos/mozilla/grcov/tags | gojq -r '.[0].name' > .ver
44+
curl -sL https://github.com/mozilla/grcov/releases/download/$(cat .ver)/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
45+
echo "$HOME/.local/bin" >> $GITHUB_PATH
46+
3847
- name: Generate test result and coverage report
3948
run: |
40-
cargo install cargo2junit grcov;
49+
cargo install cargo2junit;
4150
cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
4251
zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`;
4352
grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;
@@ -47,10 +56,10 @@ jobs:
4756
check_name: Test Results
4857
github_token: ${{ secrets.GITHUB_TOKEN }}
4958
files: results.xml
50-
- name: Upload to CodeCov
51-
uses: codecov/codecov-action@v1
52-
with:
59+
#- name: Upload to CodeCov
60+
# uses: codecov/codecov-action@v1
61+
# with:
5362
# required for private repositories:
5463
# token: ${{ secrets.CODECOV_TOKEN }}
55-
files: ./lcov.info
56-
fail_ci_if_error: true
64+
# files: ./lcov.info
65+
# fail_ci_if_error: true

Cargo.toml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
[package]
2-
name = "rust_ci_github_actions_workflow"
3-
version = "0.1.0"
4-
authors = ["[email protected]"]
5-
edition = "2018"
6-
7-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8-
9-
[features]
10-
coverage = []
11-
12-
[dependencies]
1+
[workspace]
2+
members = ["backpack", "xtask"]
3+
resolver = "2"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Rust CI with GitHub Actions
22

3-
![example workflow](https://github.com/BamPeers/rust-ci-github-actions-workflow/actions/workflows/check-and-lint.yaml/badge.svg) ![example workflow](https://github.com/BamPeers/rust-ci-github-actions-workflow/actions/workflows/test.yaml/badge.svg) [![codecov](https://codecov.io/gh/BamPeers/rust-ci-github-actions-workflow/branch/main/graph/badge.svg?token=SLIHSUWHT2)](https://codecov.io/gh/BamPeers/rust-ci-github-actions-workflow)
3+
![Linting workflow](https://github.com/yonas-forks/test2/actions/workflows/lint.yaml/badge.svg) ![testing workflow](https://github.com/yonas-forks/test2/actions/workflows/test.yaml/badge.svg) ![packaging](https://github.com/yonas-forks/test2/actions/workflows/release-packaging.yaml/badge.svg) ![coverage](https://github.com/yonas-forks/test2/actions/workflows/coverage.yaml/badge.svg) [![codecov](https://codecov.io/gh/yonas-forks/test2/branch/main/graph/badge.svg?token=SLIHSUWHT2)](https://codecov.io/gh/yonas-forks/test2)
44

55

66
## Table of Contents
@@ -17,7 +17,7 @@ The CI process is separated into 3 workflows: Check and Lint, Test, and Release
1717

1818
All jobs run on `ubuntu-latest`, and are run in parallel.
1919

20-
All jobs use [actions/checkout@v2](https://github.com/actions/checkout) and [actions-rs/toolchain@v1](https://github.com/actions-rs/toolchain).
20+
All jobs use [actions/checkout](https://github.com/actions/checkout) and [actions-rs/toolchain](https://github.com/actions-rs/toolchain).
2121

2222
<a name="check-and-lint"></a>
2323

backpack/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "test2"
3+
version = "0.1.0"
4+
authors = ["[email protected]"]
5+
edition = "2021"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[[bin]]
10+
name = "test2"
11+
path = "src/main.rs"
12+
13+
[features]
14+
coverage = []
15+
16+
[dependencies]
File renamed without changes.

src/main.rs renamed to backpack/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rust_ci_github_actions_workflow::*;
1+
use test2::*;
22

33
fn main() {
44
println!("3 time 5 is {}", multiply(3, 5));

0 commit comments

Comments
 (0)