Skip to content

Commit

Permalink
[PLATFORM-1405]: Check that jwks_client package version is the same a…
Browse files Browse the repository at this point in the history
…s the tag (#25)

* Refactor ci, cd and Makefile

* Remove build file

* Check package version in cd

* Fix wrong error msg in cd

* Add fmt-check task

* Fix clippy warning

* Format...
  • Loading branch information
cottinisimone authored Nov 29, 2023
1 parent fb31f40 commit be9f56d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 118 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install cargo-release
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: login
run: cargo login "$CARGO_AUTH_KEY"
- uses: taiki-e/install-action@cargo-release
- uses: taiki-e/install-action@cargo-make
- name: Get version
run: |
VERSION=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check version
if: ${{ github.event.release.tag_name != env.VERSION }}
run: |
echo "Github ref tag [${{ github.event.release.tag_name }}] is different from Cargo.toml version [${{ env.VERSION }}]"
exit 1
- run: cargo login "$CARGO_AUTH_KEY"
env:
CARGO_AUTH_KEY: ${{ secrets.CARGO_AUTH_KEY }}
- name: publish
run: cargo release publish --no-confirm --allow-branch "*" --all-features --execute
- run: cargo make release
19 changes: 7 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,20 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --all-features
- name: cargo fmt
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-features -- -D warnings
- name: Build docs
run: cargo doc --document-private-items --all-features --no-deps
env:
RUSTDOCFLAGS: -Dwarnings
- uses: taiki-e/install-action@cargo-make
- run: cargo make fmt-check
- run: cargo make clippy
- run: cargo make docs

test:
# Avoid duplicate jobs on PR from a branch on the same repo
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test
- uses: taiki-e/install-action@cargo-make
- run: cargo make test

alls-green:
if: always() && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
Expand Down
72 changes: 14 additions & 58 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,26 @@ args = [
"@@split(CARGO_MAKE_CARGO_BUILD_TEST_FLAGS, )",
]

[tasks.test]
[tasks.fmt-check]
description = "Runs the cargo rustfmt plugin."
command = "cargo"
args = ["test", "${@}"]
args = ["fmt", "--", "--check"]

[tasks.clippy]
command = "cargo"
args = ["clippy", "--", "-D", "warnings"]

[tasks.clean]
command = "cargo"
args = ["clean"]

[tasks.format-ci]
description = "Runs the cargo rustfmt plugin during CI."
command = "cargo"
args = ["fmt", "--all", "--", "--check"]

[tasks.clippy-ci]
command = "cargo"
args = ["clippy", "--", "-D", "warnings"]

[tasks.build-ci]
description = "Build inside CI."
[tasks.test]
command = "cargo"
args = ["build", "-j", "2", "--all-features"]

[tasks.cache-cleanup]
description = "Clean CI cache"
dependencies = ["cargo-prune", "sweep", "delete-artifacts"]

[tasks.sweep]
description = "Clean cargo cache with sweep"
command = "cargo sweep -t 10"
ignore_errors = true
args = ["test", "${@}", "--all-features"]

[tasks.cargo-prune]
description = "Run cargo prune"
[tasks.clippy]
command = "cargo"
args = ["prune"]

[tasks.delete-artifacts]
description = "Remove non cachable artifacts"
script = [
'''
#!/bin/bash
set -e
set -x
find ./target/debug -type f -maxdepth 1 -delete || true
rm -rfv ./target/{debug,release}/deps/{*jwks_client*}
rm -rfv ./target/{debug,release}/.fingerprint/*jwks_client*
'''
]
args = ["clippy", "--all-features", "--all-targets", "--", "-D", "warnings"]

[tasks.sweep-start]
description = "Start cargo sweep"
[tasks.docs]
description = "Build docs as they are rendered on docs.rs"
command = "cargo"
args = ["sweep", "-s"]
args = ["doc", "--document-private-items", "--all-features", "--no-deps"]
env = { "RUSTDOCFLAGS" = "-Dwarnings" }

[tasks.sweep-end]
description = "Run cargo sweep cleanup"
[tasks.release]
description = "Task to release the package to crates.io"
command = "cargo"
args = ["sweep", "-f"]

[tasks.print-stats]
description = "Print cache size"
command = "du"
args = ["-sh", "target", ".cargo"]
args = ["release", "publish", "--no-confirm", "--allow-branch \"*\"", "--all-features", "--execute"]
36 changes: 0 additions & 36 deletions deploy/build

This file was deleted.

5 changes: 1 addition & 4 deletions examples/get_jwks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ async fn main() {

// The kid "unknown" cannot be a JWKS valid KID. This must not be found here
let result: Result<JsonWebKey, JwksClientError> = client.get("unknown").await;
println!(
"Get with kid \"unknown\": {}",
result.unwrap_err().to_string()
);
println!("Get with kid \"unknown\": {}", result.unwrap_err());

// The provided kid (assuming is the same you got from your tenant) is valid and could be found.
let result: Result<JsonWebKey, JwksClientError> = client.get(&kid).await;
Expand Down

0 comments on commit be9f56d

Please sign in to comment.