Skip to content

Commit 5f4c7f1

Browse files
authored
chore: Ease code contributions (#1461)
- Add few more statements to the contributions guide. - Make ci/committed/lintes workflows run without waiting for approval.
1 parent f1906c3 commit 5f4c7f1

File tree

4 files changed

+77
-39
lines changed

4 files changed

+77
-39
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ jobs:
6363
with:
6464
tool: cargo-nextest
6565

66-
- name: Rust Cache
67-
uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
68-
6966
- name: Run tests
7067
run: cargo nextest run ${{ matrix.test_args }} --all-features
7168

@@ -88,9 +85,6 @@ jobs:
8885
with:
8986
toolchain: nightly
9087

91-
- name: Rust Cache
92-
uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
93-
9488
- name: Install cargo-fuzz
9589
run: |
9690
cargo install cargo-fuzz
@@ -101,16 +95,18 @@ jobs:
10195
mock:
10296
runs-on: ubuntu-latest
10397
steps:
98+
- name: Harden Runner
99+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
100+
with:
101+
egress-policy: audit
102+
104103
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
105104

106105
- name: Install Rust
107106
uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
108107
with:
109108
toolchain: stable
110109

111-
- name: Rust Cache
112-
uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
113-
114110
- name: Start prism mock server - BlockStorage
115111
run: |
116112
docker run --init --rm -d -v "$GITHUB_WORKSPACE/openstack_types/data":"/data" -p 4010:4010 stoplight/prism:4 mock -h 0.0.0.0 /data/block-storage/v3.yaml -d

.github/workflows/committed.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Not run as part of pre-commit checks because they don't handle sending the correct commit
22
# range to `committed`
33
name: Lint Commits
4-
on: [pull_request]
4+
on:
5+
pull_request:
56

6-
permissions: read-all
7+
permissions:
8+
contents: read
79

810
env:
911
RUST_BACKTRACE: 1
@@ -16,15 +18,15 @@ jobs:
1618
runs-on: ubuntu-latest
1719
steps:
1820

19-
- name: Harden Runner
20-
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
21-
with:
22-
egress-policy: audit
21+
- name: Harden Runner
22+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
23+
with:
24+
egress-policy: audit
2325

24-
- name: Checkout Actions Repository
25-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
26-
with:
27-
fetch-depth: 0
26+
- name: Checkout Actions Repository
27+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
28+
with:
29+
fetch-depth: 0
2830

29-
- name: Lint Commits
30-
uses: crate-ci/committed@15229711f8f597474c0b636f327cde5969f9a529 # v1.1.7
31+
- name: Lint Commits
32+
uses: crate-ci/committed@15229711f8f597474c0b636f327cde5969f9a529 # v1.1.7

.github/workflows/linters.yml

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,35 @@ jobs:
4444
toolchain: stable
4545
components: rustfmt
4646

47-
- uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
48-
4947
- name: Run rustfmt
5048
run: cargo fmt -- --check
5149

5250
clippy:
5351
name: Run clippy on the minimum supported toolchain
5452
runs-on: ubuntu-latest
53+
# reduce job-level privileges so this job can run for forked PRs without requiring maintainer approval
5554
permissions:
5655
contents: read
57-
security-events: write
5856
steps:
59-
6057
- name: Harden Runner
6158
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
6259
with:
6360
egress-policy: audit
6461

6562
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
63+
with:
64+
ref: ${{ github.event.pull_request.head.sha }}
65+
persist-credentials: false
66+
67+
- name: Ensure bash is installed
68+
run: sudo apt-get update && sudo apt-get install -y bash
6669

6770
- name: Install Rust
6871
uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
6972
with:
7073
toolchain: stable
7174
components: rustfmt, clippy
7275

73-
- uses: swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2.8.0
74-
7576
- name: Install cargo-binstall
7677
uses: taiki-e/install-action@f37a1e4d34f3e1c6a571e294b0258f2805eab48d # v2.58.4
7778
with:
@@ -87,6 +88,39 @@ jobs:
8788
--all-features
8889
--message-format=json | ${CARGO_HOME}/bin/clippy-sarif | tee rust-clippy-results.sarif | ${CARGO_HOME}/bin/sarif-fmt
8990

91+
- name: Upload SARIF as artifact (so a separate, trusted job can upload to GitHub)
92+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
93+
with:
94+
name: rust-clippy-results
95+
path: rust-clippy-results.sarif
96+
97+
upload-sarif:
98+
name: Upload CodeQL results
99+
needs: clippy
100+
runs-on: ubuntu-latest
101+
# grant the write permission only to this job (trusted execution)
102+
permissions:
103+
contents: read
104+
security-events: write
105+
# Only run the upload step for trusted contexts:
106+
# - pushes (e.g. push to main)
107+
# - pull requests whose head repo is not a fork (i.e. runs from trusted repository)
108+
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) }}
109+
steps:
110+
111+
- name: Harden Runner
112+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
113+
with:
114+
egress-policy: audit
115+
116+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
117+
118+
- name: Download SARIF artifact
119+
uses: actions/download-artifact@abefc31eafcfbdf6c5336127c1346fdae79ff41c # v5.0.0
120+
with:
121+
name: rust-clippy-results
122+
path: .
123+
90124
- name: Upload analysis results to GitHub
91125
uses: github/codeql-action/upload-sarif@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.30.0
92126
with:
@@ -97,15 +131,15 @@ jobs:
97131
name: Spell Check with Typos
98132
runs-on: ubuntu-latest
99133
steps:
100-
- name: Harden Runner
101-
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
102-
with:
103-
egress-policy: audit
104-
105-
- name: Checkout Actions Repository
106-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
107-
108-
- name: Check spelling of file.txt
109-
uses: crate-ci/typos@7436548694def3314aacd93ed06c721b1f91ea04 # v1.37.2
110-
with:
111-
config: typos.toml
134+
- name: Harden Runner
135+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
136+
with:
137+
egress-policy: audit
138+
139+
- name: Checkout Actions Repository
140+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
141+
142+
- name: Check for typos
143+
uses: crate-ci/typos@7436548694def3314aacd93ed06c721b1f91ea04 # v1.37.2
144+
with:
145+
config: typos.toml

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ if you have an idea how generated code can be improved open an issue or discussi
4848
fixed upstream. The only exception is that during code generation spelling
4949
issues are automatically addressed by `typos -w`.
5050

51+
- Merge commits are forbidden. Whenever you open a PR please update it with
52+
rebase and not a merge commit. It is also recommended to "allow edits from
53+
maintainers" to help us get the quick fixes to the PR.
54+
55+
- PRs are merged as squash commits.
56+
5157
## Releasing
5258

5359
There are 2 projects being used to take care of release process:

0 commit comments

Comments
 (0)