Also automatically run cargo-fix after rustfmt.
This commit is contained in:
parent
db0ea7394e
commit
b3c638428b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user