Skip to content

Commit 82111c5

Browse files
authored
Merge pull request #1776 from analysis-tools-dev/add-pr-check
Add automated PR check for contributing criteria
2 parents 9aa5fbf + c1afc8f commit 82111c5

File tree

23 files changed

+4469
-27
lines changed

23 files changed

+4469
-27
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
12+
13+
- name: Install Rust toolchain
14+
uses: dtolnay/rust-toolchain@stable
1215

1316
- name: Prevent file change
1417
uses: xalvarez/prevent-file-change-action@v1

.github/workflows/pr-check.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: PR Check
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
paths:
7+
- "data/tools/**.yml"
8+
- "ci/**"
9+
workflow_dispatch:
10+
inputs:
11+
pr_number:
12+
description: "PR number to check"
13+
required: true
14+
tool_files:
15+
description: "Space-separated list of tool YAML files to check (e.g. data/tools/foo.yml)"
16+
required: true
17+
18+
jobs:
19+
pr-check:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
pull-requests: write
23+
contents: read
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Get changed tool files
30+
id: changed
31+
run: |
32+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
33+
FILES="${{ inputs.tool_files }}"
34+
else
35+
FILES=$(git diff --name-only --diff-filter=A origin/master...HEAD -- 'data/tools/*.yml' | tr '\n' ' ')
36+
fi
37+
echo "files=$FILES" >> "$GITHUB_OUTPUT"
38+
39+
- name: Install Rust toolchain
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Cache cargo registry
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
~/.cargo/registry
47+
~/.cargo/git
48+
ci/target
49+
key: pr-check-${{ runner.os }}-${{ hashFiles('ci/Cargo.lock') }}
50+
restore-keys: |
51+
pr-check-${{ runner.os }}-
52+
53+
- name: Build pr-check
54+
run: cargo build --release --manifest-path ci/Cargo.toml -p pr-check
55+
56+
- name: Run pr-check
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
GITHUB_REPOSITORY: ${{ github.repository }}
60+
PR_NUMBER: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || github.event.pull_request.number }}
61+
run: |
62+
ci/target/release/pr-check ${{ steps.changed.outputs.files }}

.github/workflows/render.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10-
10+
1111
permissions:
1212
# Give the default GITHUB_TOKEN write permission to commit and push the
1313
# added or changed files to the repository.
1414
contents: write
1515

1616
steps:
17-
- uses: actions/checkout@v3
18-
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Rust toolchain
20+
uses: dtolnay/rust-toolchain@stable
21+
1922
- name: Render list
2023
run: make render
2124
env:
2225
GITHUB_TOKEN: ${{ github.token }}
23-
26+
2427
- uses: stefanzweifel/git-auto-commit-action@v4.1.2
2528
with:
2629
commit_message: Commit list

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
logcli-linux-amd64
2-
logcli.zip
2+
logcli.zip
3+
ci/target/
4+
ci/pr-check/target/

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ help:
1616

1717
# Main rendering targets
1818
render:
19-
cargo run --manifest-path data/render/Cargo.toml -- --tags data/tags.yml --tools data/tools --md-out README.md --json-out data/api
19+
cargo run --manifest-path ci/Cargo.toml -p render -- --tags data/tags.yml --tools data/tools --md-out README.md --json-out data/api
2020

2121
render-skip-deprecated:
22-
cargo run --manifest-path data/render/Cargo.toml -- --tags data/tags.yml --tools data/tools --md-out README.md --json-out data/api --skip-deprecated
22+
cargo run --manifest-path ci/Cargo.toml -p render -- --tags data/tags.yml --tools data/tools --md-out README.md --json-out data/api --skip-deprecated
2323

2424
# Development targets
2525
check:
26-
cargo check --manifest-path data/render/Cargo.toml
26+
cargo check --manifest-path ci/Cargo.toml
2727

2828
clippy:
29-
cargo clippy --manifest-path data/render/Cargo.toml -- -D warnings
29+
cargo clippy --manifest-path ci/Cargo.toml -- -D warnings
3030

3131
fmt:
32-
cargo fmt --manifest-path data/render/Cargo.toml
32+
cargo fmt --manifest-path ci/Cargo.toml
3333

3434
test:
35-
cargo test --manifest-path data/render/Cargo.toml
35+
cargo test --manifest-path ci/Cargo.toml
3636

3737
clean:
38-
cargo clean --manifest-path data/render/Cargo.toml
38+
cargo clean --manifest-path ci/Cargo.toml

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- 🚨🚨 DON'T EDIT THIS FILE DIRECTLY. Edit `data/tools.yml` instead. 🚨🚨 -->
1+
<!-- 🚨🚨 DON'T EDIT THIS FILE DIRECTLY. Add a file to `data/tools/` instead. 🚨🚨 -->
22

33
<a href="https://analysis-tools.dev/">
44
<img alt="Analysis Tools Website" src="https://raw.githubusercontent.com/analysis-tools-dev/assets/master/static/redesign.svg" />

0 commit comments

Comments
 (0)