Skip to content

Commit 6c7abd2

Browse files
authored
chore(ci): fix issues found by Zizmor (#127)
1 parent c1f9d3f commit 6c7abd2

File tree

7 files changed

+68
-40
lines changed

7 files changed

+68
-40
lines changed

.github/workflows/changelog.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@ name: Ensure CHANGELOG updated
22

33
on:
44
pull_request:
5-
types: [ assigned, opened, synchronize, reopened, labeled, unlabeled ]
6-
branches: [ main ]
5+
types: [assigned, opened, synchronize, reopened, labeled, unlabeled]
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
checks: write
711

812
jobs:
913
changelog:
1014
name: Ensure changelog updated
1115
runs-on: ubuntu-latest
1216
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
with:
20+
persist-credentials: false
1321
- name: Changelog check
14-
uses: Zomzog/changelog-checker@v1.2.0
22+
uses: Zomzog/changelog-checker@564f4aa7a062e7498bd253f616569f02fb024c06 # v1.2.0
1523
with:
1624
fileName: CHANGELOG.md
1725
noChangelogLabel: no-changelog

.github/workflows/rust.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
env:
1010
CARGO_TERM_COLOR: always
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
check:
1417
name: Check
1518
runs-on: ubuntu-latest
1619
steps:
1720
- name: Checkout sources
18-
uses: actions/checkout@v4
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
with:
23+
persist-credentials: false
1924

2025
- name: Install Rust toolchain
21-
uses: moonrepo/setup-rust@v1
26+
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
2227

2328
- name: Run cargo check
2429
run: cargo check --features reqwest --all-targets
@@ -28,10 +33,12 @@ jobs:
2833
runs-on: ubuntu-latest
2934
steps:
3035
- name: Checkout sources
31-
uses: actions/checkout@v4
36+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
37+
with:
38+
persist-credentials: false
3239

3340
- name: Install Rust toolchain
34-
uses: moonrepo/setup-rust@v1
41+
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
3542

3643
- name: Run cargo test
3744
run: cargo test --features reqwest --all-targets
@@ -41,10 +48,12 @@ jobs:
4148
runs-on: ubuntu-latest
4249
steps:
4350
- name: Checkout sources
44-
uses: actions/checkout@v4
51+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
52+
with:
53+
persist-credentials: false
4554

4655
- name: Install Rust toolchain
47-
uses: moonrepo/setup-rust@v1
56+
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
4857
with:
4958
components: rustfmt
5059

@@ -56,10 +65,12 @@ jobs:
5665
runs-on: ubuntu-latest
5766
steps:
5867
- name: Checkout sources
59-
uses: actions/checkout@v4
68+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
69+
with:
70+
persist-credentials: false
6071

6172
- name: Install Rust toolchain
62-
uses: moonrepo/setup-rust@v1
73+
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
6374
with:
6475
components: clippy
6576

@@ -73,10 +84,12 @@ jobs:
7384
runs-on: ubuntu-latest
7485
steps:
7586
- name: Checkout sources
76-
uses: actions/checkout@v4
87+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
88+
with:
89+
persist-credentials: false
7790

7891
- name: Install Rust toolchain
79-
uses: moonrepo/setup-rust@v1
92+
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
8093

8194
- name: Run cargo doc
8295
run: cargo doc --no-deps --features reqwest --document-private-items

.github/workflows/rustdoc.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
name: rustdoc
22
on:
33
push:
4-
branches:
5-
- main
4+
branches:
5+
- main
66

77
env:
88
CARGO_INCREMENTAL: 0
99
CARGO_NET_RETRY: 10
1010
RUSTDOCFLAGS: "-D warnings -W unreachable-pub --cfg docsrs"
1111
RUSTUP_MAX_RETRIES: 10
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
rustdoc:
1518
runs-on: ubuntu-latest
1619

1720
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v4
21+
- name: Checkout repository
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
with:
24+
persist-credentials: false
2025

21-
- name: Install Rust toolchain
22-
uses: moonrepo/setup-rust@v1
23-
with:
24-
channel: nightly
25-
components: rustfmt, rust-src
26+
- name: Install Rust toolchain
27+
uses: moonrepo/setup-rust@ede6de059f8046a5e236c94046823e2af11ca670 # v1.2.2
28+
with:
29+
channel: nightly
30+
components: rustfmt, rust-src
2631

27-
- name: Build Documentation
28-
run: cargo +nightly doc --no-deps --features reqwest
32+
- name: Build Documentation
33+
run: cargo +nightly doc --no-deps --features reqwest
2934

30-
- name: Deploy Docs
31-
uses: peaceiris/actions-gh-pages@v4.0.0
32-
with:
33-
personal_token: ${{ secrets.GITHUB_TOKEN }}
34-
publish_branch: gh-pages
35-
publish_dir: ./target/doc
36-
force_orphan: true
35+
- name: Deploy Docs
36+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
37+
with:
38+
personal_token: ${{ secrets.GITHUB_TOKEN }}
39+
publish_branch: gh-pages
40+
publish_dir: ./target/doc
41+
force_orphan: true

crates/grafana-plugin-sdk/src/backend/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,11 @@ where
733733
{
734734
// Grafana sometimes sends an empty string instead of an empty map, probably
735735
// because of some zero value Golang stuff?
736-
let jdoc = jdoc.is_empty().then(|| b"{}".as_slice()).unwrap_or(jdoc);
736+
let jdoc = if jdoc.is_empty() {
737+
b"{}".as_slice()
738+
} else {
739+
jdoc
740+
};
737741
serde_json::from_slice(jdoc)
738742
}
739743

crates/grafana-plugin-sdk/src/backend/tracing_fmt.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,9 @@ impl<'a> io::Write for WriteAdaptor<'a> {
273273
let s =
274274
std::str::from_utf8(buf).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
275275

276-
self.fmt_write
277-
.write_str(s)
278-
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
276+
self.fmt_write.write_str(s).map_err(io::Error::other)?;
279277

280-
Ok(s.as_bytes().len())
278+
Ok(s.len())
281279
}
282280

283281
fn flush(&mut self) -> io::Result<()> {

crates/grafana-plugin-sdk/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ the [crate examples] or [sample app repo] to get started with writing a backend
2424
The following feature flags enable additional functionality for this crate:
2525
2626
- `reqwest` - adds an [`IntoHttpResponse`][crate::backend::IntoHttpResponse] implementation for
27-
[`reqwest::Response`]
27+
[`reqwest::Response`]
2828
2929
[Backend plugins on grafana.com]: https://grafana.com/docs/grafana/latest/developers/plugins/backend/
3030
[Grafana Live]: https://grafana.com/docs/grafana/latest/live/

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "1.81.0"
2+
channel = "1.87.0"
33
components = ["rustfmt", "clippy", "rust-analyzer"]

0 commit comments

Comments
 (0)