Also automatically run cargo-fix after rustfmt.
semver Build semver has succeeded Details
rustfmt Build rustfmt has failed Details
rust-test Build rust-test has succeeded Details

This commit is contained in:
Tom Alexander 2023-07-18 13:42:09 -04:00
parent db0ea7394e
commit b3c638428b
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 30 additions and 10 deletions

View File

@ -14,13 +14,13 @@ spec:
- name: path-to-dockerfile
description: The path to the Dockerfile
type: string
- name: command
- name: rustfmt-command
type: array
description: Command to run.
description: Command to run rustfmt.
default: []
- name: args
- name: rustfmt-args
type: array
description: Arguments passed to command.
description: Arguments passed to rustfmt.
default: []
- name: GIT_USER_NAME
description: The username for git
@ -119,19 +119,36 @@ spec:
runAfter:
- fetch-repository
- detect-tag
- name: run-image
- name: rustfmt
taskRef:
name: run-docker-image
workspaces:
- name: source
workspace: git-source
- name: cargo-cache
workspace: cargo-cache
runAfter:
- build-image
params:
- name: command
value: ["$(params.rustfmt-command[*])"]
- name: args
value: ["$(params.rustfmt-args[*])"]
- name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
- name: cargo-fix
taskRef:
name: run-docker-image
workspaces:
- name: source
workspace: git-source
runAfter:
- build-image
- rustfmt
params:
- name: command
value: ["$(params.command[*])"]
value: ["cargo", "fix"]
- name: args
value: ["$(params.args[*])"]
value: ["--allow-dirty"]
- name: docker-image
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
- name: commit-changes
@ -148,7 +165,7 @@ spec:
git config --global --add safe.directory /workspace/source
git_status=$(git status --porcelain)
if [ -n "$git_status" ]; then
git commit -a -m "CI: format rust code."
git commit -a -m "CI: autofix rust code."
git push origin HEAD:$(params.PULL_BASE_REF)
else
echo "No changes to commit."
@ -157,7 +174,7 @@ spec:
- name: source
workspace: git-source
runAfter:
- run-image
- cargo-fix
finally:
- name: report-success
when:
@ -217,6 +234,9 @@ spec:
requests:
storage: 10Gi
subPath: rust-source
- name: cargo-cache
persistentVolumeClaim:
claimName: cargo-cache
- name: docker-credentials
secret:
secretName: harbor-plain