Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 05abc1a

Browse files
alvicsamparitytech-ci
and
paritytech-ci
authored
[ci] add auto cargo-fmt (#1562)
* [WIP][ci] add auto cargo-fmt * [ci] Apply cargo-fmt * use fmt nightly * [ci] Apply cargo-fmt * add comment to cargo-fmt and remove fmt gha Co-authored-by: paritytech-ci <paritytech-ci@parity.io>
1 parent 8637376 commit 05abc1a

File tree

2 files changed

+36
-40
lines changed

2 files changed

+36
-40
lines changed

.github/workflows/quick-check.yml

-40
This file was deleted.

.gitlab-ci.yml

+36
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ variables:
6969
- if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9].*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1, release-parachains-v3000
7070
- if: $CI_COMMIT_REF_NAME =~ /^polkadot-v[0-9]+\.[0-9]+.*$/ # i.e. polkadot-v1.0.99, polkadot-v2.1rc1
7171

72+
.pr-refs: &pr-refs
73+
# these jobs run always*
74+
rules:
75+
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
76+
7277
.publish-refs: &publish-refs
7378
rules:
7479
- if: $CI_COMMIT_REF_NAME == "master"
@@ -107,6 +112,23 @@ variables:
107112
tags:
108113
- kubernetes-parity-build
109114

115+
#### stage: .pre
116+
117+
# checks code format and fails if formatting is required
118+
# the code will be formatted automatically and the pipeline will be restarted
119+
cargo-fmt:
120+
stage: .pre
121+
<<: *pr-refs
122+
<<: *kubernetes-env
123+
before_script:
124+
- echo PROJECT_NAME=$CI_PROJECT_NAME > fmt.env
125+
- echo PR_BRANCH_NAME=$(curl -s https://api.github.com/repos/paritytech/${CI_PROJECT_NAME}/pulls/${CI_COMMIT_REF_NAME} | jq -r ".head.ref") >> fmt.env
126+
script:
127+
- cargo +nightly fmt --check
128+
artifacts:
129+
reports:
130+
dotenv: fmt.env
131+
110132
#### stage: test
111133

112134
test-linux-stable:
@@ -601,3 +623,17 @@ cancel-pipeline:
601623
project: "parity/infrastructure/ci_cd/pipeline-stopper"
602624
# remove branch, when pipeline-stopper for substrate and polakdot is updated to the same branch
603625
branch: "as-improve"
626+
627+
# this job will automatically format code and rerun pipeline if cargo-fmt job fails
628+
auto-fmt:
629+
stage: .post
630+
rules:
631+
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
632+
when: on_failure
633+
needs:
634+
- job: cargo-fmt
635+
variables:
636+
PROJECT_NAME: "${CI_PROJECT_NAME}"
637+
PR_BRANCH_NAME: "${PR_BRANCH_NAME}"
638+
trigger:
639+
project: "parity/infrastructure/ci_cd/auto-fmt"

0 commit comments

Comments
 (0)