From 1bebf7f4723c82abb6339cfd3846829be6e318d4 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 20 Jan 2023 16:36:12 +0100 Subject: [PATCH 1/4] [ci] Change check-labels GHA --- .github/workflows/check-D-labels.yml | 51 ++++++++++++++++++++++++++++ .github/workflows/check-labels.yml | 41 +++++++++++++++++----- 2 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/check-D-labels.yml diff --git a/.github/workflows/check-D-labels.yml b/.github/workflows/check-D-labels.yml new file mode 100644 index 000000000000..4a32bf53d43c --- /dev/null +++ b/.github/workflows/check-D-labels.yml @@ -0,0 +1,51 @@ +name: Check D labels + +on: + pull_request: + types: [labeled, opened, synchronize, unlabeled] + paths: + - runtime/polkadot/** + - runtime/kusama/** + - runtime/common/** + - primitives/src/** + +jobs: + check-labels: + runs-on: ubuntu-latest + steps: + - name: Pull image + env: + IMAGE: paritytech/ruled_labels:0.3.2 + run: docker pull $IMAGE + + - name: Check labels + env: + IMAGE: paritytech/ruled_labels:0.3.2 + MOUNT: /work + GITHUB_PR: ${{ github.event.pull_request.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + API_BASE: https://api.github.com/repos + REPO: ${{ github.repository }} + RULES_PATH: labels/ruled_labels + CHECK_SPECS: specs_cumulus.yaml + run: | + echo "REPO: ${REPO}" + echo "GITHUB_PR: ${GITHUB_PR}" + # Clone repo with labels specs + git clone https://github.com/paritytech/labels + # Fetch the labels for the PR under test + labels=$( curl -H "Authorization: token ${GITHUB_TOKEN}" -s "$API_BASE/${REPO}/pulls/${GITHUB_PR}" | jq '.labels | .[] | .name' | tr "\n" ",") + + if [ -z "${labels}" ]; then + echo "No labels found. Please add labels D labels" + exit 1 + fi + + labels_args=${labels: :-1} + printf "Checking labels: %s\n" "${labels_args}" + + # Prevent the shell from splitting labels with spaces + IFS="," + + # --dev is more useful to debug mode to debug + docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --labels ${labels_args} --dev --tags audit diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml index f0f5556ebede..f524dad13d0d 100644 --- a/.github/workflows/check-labels.yml +++ b/.github/workflows/check-labels.yml @@ -8,16 +8,39 @@ jobs: check-labels: runs-on: ubuntu-latest steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Pull image + env: + IMAGE: paritytech/ruled_labels:0.3.2 + run: docker pull $IMAGE + - name: Check labels - run: bash ${{ github.workspace }}/scripts/ci/github/check_labels.sh env: + IMAGE: paritytech/ruled_labels:0.3.2 + MOUNT: /work GITHUB_PR: ${{ github.event.pull_request.number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} + API_BASE: https://api.github.com/repos + REPO: ${{ github.repository }} + RULES_PATH: labels/ruled_labels + CHECK_SPECS: specs_cumulus.yaml + run: | + echo "REPO: ${REPO}" + echo "GITHUB_PR: ${GITHUB_PR}" + # Clone repo with labels specs + git clone https://github.com/paritytech/labels + # Fetch the labels for the PR under test + labels=$( curl -H "Authorization: token ${GITHUB_TOKEN}" -s "$API_BASE/${REPO}/pulls/${GITHUB_PR}" | jq '.labels | .[] | .name' | tr "\n" ",") + + if [ -z "${labels}" ]; then + echo "No labels found. Please add labels A, B and C labels" + exit 1 + fi + + labels_args=${labels: :-1} + printf "Checking labels: %s\n" "${labels_args}" + + # Prevent the shell from splitting labels with spaces + IFS="," + + # --dev is more useful to debug mode to debug + docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --labels ${labels_args} --dev --tags PR From cd1bbb5b1fa2fa6e192b4738f3ee26c85ec0af89 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Fri, 20 Jan 2023 16:37:11 +0100 Subject: [PATCH 2/4] change file spec name --- .github/workflows/check-D-labels.yml | 2 +- .github/workflows/check-labels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-D-labels.yml b/.github/workflows/check-D-labels.yml index 4a32bf53d43c..765cc1803886 100644 --- a/.github/workflows/check-D-labels.yml +++ b/.github/workflows/check-D-labels.yml @@ -27,7 +27,7 @@ jobs: API_BASE: https://api.github.com/repos REPO: ${{ github.repository }} RULES_PATH: labels/ruled_labels - CHECK_SPECS: specs_cumulus.yaml + CHECK_SPECS: specs_polkadot.yaml run: | echo "REPO: ${REPO}" echo "GITHUB_PR: ${GITHUB_PR}" diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml index f524dad13d0d..1ec6d6c3d9e6 100644 --- a/.github/workflows/check-labels.yml +++ b/.github/workflows/check-labels.yml @@ -22,7 +22,7 @@ jobs: API_BASE: https://api.github.com/repos REPO: ${{ github.repository }} RULES_PATH: labels/ruled_labels - CHECK_SPECS: specs_cumulus.yaml + CHECK_SPECS: specs_polkadot.yaml run: | echo "REPO: ${REPO}" echo "GITHUB_PR: ${GITHUB_PR}" From c9a24b0be2198d45952b4ccd08c4f6ac5b6e8eb7 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 23 Jan 2023 16:42:05 +0100 Subject: [PATCH 3/4] change script when no label --- .github/workflows/auto-label-prs.yml | 21 --------------------- .github/workflows/check-D-labels.yml | 7 +++---- .github/workflows/check-labels.yml | 7 +++---- 3 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 .github/workflows/auto-label-prs.yml diff --git a/.github/workflows/auto-label-prs.yml b/.github/workflows/auto-label-prs.yml deleted file mode 100644 index 50539b80b98b..000000000000 --- a/.github/workflows/auto-label-prs.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Label PRs -on: - pull_request: - types: [opened,ready_for_review] - -jobs: - label-new-prs: - runs-on: ubuntu-latest - steps: - - name: Label drafts - uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # 1.0.4 - if: github.event.pull_request.draft == true - with: - add-labels: 'A3-inprogress' - remove-labels: 'A0-pleasereview' - - name: Label PRs - uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # 1.0.4 - if: github.event.pull_request.draft == false && ! contains(github.event.pull_request.labels.*.name, 'A2-insubstantial') - with: - add-labels: 'A0-pleasereview' - remove-labels: 'A3-inprogress' diff --git a/.github/workflows/check-D-labels.yml b/.github/workflows/check-D-labels.yml index 765cc1803886..cbbf7462ab4b 100644 --- a/.github/workflows/check-D-labels.yml +++ b/.github/workflows/check-D-labels.yml @@ -15,12 +15,12 @@ jobs: steps: - name: Pull image env: - IMAGE: paritytech/ruled_labels:0.3.2 + IMAGE: paritytech/ruled_labels:0.4.0 run: docker pull $IMAGE - name: Check labels env: - IMAGE: paritytech/ruled_labels:0.3.2 + IMAGE: paritytech/ruled_labels:0.4.0 MOUNT: /work GITHUB_PR: ${{ github.event.pull_request.number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -37,8 +37,7 @@ jobs: labels=$( curl -H "Authorization: token ${GITHUB_TOKEN}" -s "$API_BASE/${REPO}/pulls/${GITHUB_PR}" | jq '.labels | .[] | .name' | tr "\n" ",") if [ -z "${labels}" ]; then - echo "No labels found. Please add labels D labels" - exit 1 + docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --no-label fi labels_args=${labels: :-1} diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml index 1ec6d6c3d9e6..00b6351137cd 100644 --- a/.github/workflows/check-labels.yml +++ b/.github/workflows/check-labels.yml @@ -10,12 +10,12 @@ jobs: steps: - name: Pull image env: - IMAGE: paritytech/ruled_labels:0.3.2 + IMAGE: paritytech/ruled_labels:0.4.0 run: docker pull $IMAGE - name: Check labels env: - IMAGE: paritytech/ruled_labels:0.3.2 + IMAGE: paritytech/ruled_labels:0.4.0 MOUNT: /work GITHUB_PR: ${{ github.event.pull_request.number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -32,8 +32,7 @@ jobs: labels=$( curl -H "Authorization: token ${GITHUB_TOKEN}" -s "$API_BASE/${REPO}/pulls/${GITHUB_PR}" | jq '.labels | .[] | .name' | tr "\n" ",") if [ -z "${labels}" ]; then - echo "No labels found. Please add labels A, B and C labels" - exit 1 + docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --no-label fi labels_args=${labels: :-1} From 7e2116578ad19c1f030a2c66252e1c6cceb99630 Mon Sep 17 00:00:00 2001 From: alvicsam Date: Mon, 23 Jan 2023 16:45:50 +0100 Subject: [PATCH 4/4] add tags --- .github/workflows/check-D-labels.yml | 2 +- .github/workflows/check-labels.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-D-labels.yml b/.github/workflows/check-D-labels.yml index cbbf7462ab4b..9abefaa6fa10 100644 --- a/.github/workflows/check-D-labels.yml +++ b/.github/workflows/check-D-labels.yml @@ -37,7 +37,7 @@ jobs: labels=$( curl -H "Authorization: token ${GITHUB_TOKEN}" -s "$API_BASE/${REPO}/pulls/${GITHUB_PR}" | jq '.labels | .[] | .name' | tr "\n" ",") if [ -z "${labels}" ]; then - docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --no-label + docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --tags audit --no-label fi labels_args=${labels: :-1} diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml index 00b6351137cd..df0a0e9cf02d 100644 --- a/.github/workflows/check-labels.yml +++ b/.github/workflows/check-labels.yml @@ -32,7 +32,7 @@ jobs: labels=$( curl -H "Authorization: token ${GITHUB_TOKEN}" -s "$API_BASE/${REPO}/pulls/${GITHUB_PR}" | jq '.labels | .[] | .name' | tr "\n" ",") if [ -z "${labels}" ]; then - docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --no-label + docker run --rm -i -v $PWD/${RULES_PATH}/:$MOUNT $IMAGE check $MOUNT/$CHECK_SPECS --tags PR --no-label fi labels_args=${labels: :-1}