From 546f9ad242b984dcaab99374388bf78456f5d33a Mon Sep 17 00:00:00 2001 From: Tchoupinax Date: Sun, 15 Dec 2024 21:33:17 +0100 Subject: [PATCH 1/6] ci: add labeller and labels script --- .github/labeler.yml | 45 +++++++++++++++++++ .github/update-labels.sh | 23 ++++++++++ .github/workflows/main-update-labels.yaml | 32 +++++++++++++ .../workflows/pull-request-relabelling.yaml | 23 ++++++++++ 4 files changed, 123 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/update-labels.sh create mode 100644 .github/workflows/main-update-labels.yaml create mode 100644 .github/workflows/pull-request-relabelling.yaml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 000000000..8688b2782 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,45 @@ +version: v1 +labels: + - label: "semver:major" + sync: true # remove label if match failed, default: false + matcher: + title: ".*BREAKING.*" + + - label: "semver:minor" + sync: true # remove label if match failed, default: false + matcher: + title: "^feat(?!.*BREAKING).*" + + - label: "semver:patch" + sync: true # remove label if match failed, default: false + matcher: + title: "^fix(?!.*BREAKING).*" + + - label: "maintenance" + sync: true # remove label if match failed, default: false + matcher: + title: "^chore(?!.*BREAKING).*" + files: + any: + - "package.json" + + - label: "CI/CD" + sync: true # remove label if match failed, default: false + matcher: + files: + any: + - ".github/**" + + - label: "docs" + sync: true # remove label if match failed, default: false + matcher: + files: + any: + - "**/*.md" + + - label: "manifest" + sync: true # remove label if match failed, default: false + matcher: + files: + any: + - "action.yml" diff --git a/.github/update-labels.sh b/.github/update-labels.sh new file mode 100644 index 000000000..91a339691 --- /dev/null +++ b/.github/update-labels.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +REPO_NAME="iggy-rs/iggy" +API_URL="https://api.github.com/repos/$REPO_NAME/labels" + +create_label() { + local name="$1" + local color="$2" + local description="$3" + + curl -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" \ + -d '{"name": "'"$name"'", "color": "'"$color"'", "description": "'"$description"'"}' \ + "$API_URL" +} + +create_label "CI/CD" "93ecdb" "Pull requests bring CI/CD improvements." +create_label "docs" "0075ca" "Improvements or additions to documentation." +create_label "duplicate" "cfd3d7" "This issue or pull request already exists." +create_label "maintenance" "ed4d86" "Maintenance work." +create_label "manifest" "D93F0B" "Label for pull request that brings a patch change." +create_label "semver:major" "8151c5" "Label for pull request that brings a major (BREAKING) change." +create_label "semver:minor" "8af85b" "Label for pull request that brings a minor change." +create_label "semver:patch" "fef2c0" "Label for pull request that brings a patch change." diff --git a/.github/workflows/main-update-labels.yaml b/.github/workflows/main-update-labels.yaml new file mode 100644 index 000000000..64254bb5a --- /dev/null +++ b/.github/workflows/main-update-labels.yaml @@ -0,0 +1,32 @@ +name: Update repository labels +on: + push: + branches: + - main + paths: + - ".github/workflows/uptdate-label.yml" + - ".github/update-labels.sh" + +jobs: + checks: + name: Update labels + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.DEPLOY_APP_ID }} + private-key: ${{ secrets.DEPLOY_APP_KEY }} + + - name: Call script + env: + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + run: | + chmod +x .github/update-labels.sh + .github/update-labels.sh diff --git a/.github/workflows/pull-request-relabelling.yaml b/.github/workflows/pull-request-relabelling.yaml new file mode 100644 index 000000000..43c158658 --- /dev/null +++ b/.github/workflows/pull-request-relabelling.yaml @@ -0,0 +1,23 @@ +name: Relabelling +on: + pull_request: + +jobs: + check-labels: + name: Relabelling + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.DEPLOY_APP_ID }} + private-key: ${{ secrets.DEPLOY_APP_KEY }} + + # https://github.com/fuxingloh/multi-labeler + - name: labels + uses: fuxingloh/multi-labeler@v4 + with: + github-token: ${{ steps.app-token.outputs.token }} From 7c426b951af03a322a52bdc26dd5f2c12ad684a2 Mon Sep 17 00:00:00 2001 From: Tchoupinax Date: Sun, 15 Dec 2024 21:44:08 +0100 Subject: [PATCH 2/6] ci: do not start test if github files are edited --- .github/workflows/test_pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_pr.yml b/.github/workflows/test_pr.yml index 63a318e97..2d4c59480 100644 --- a/.github/workflows/test_pr.yml +++ b/.github/workflows/test_pr.yml @@ -12,7 +12,9 @@ on: pull_request: branches: - master - types: [ opened, synchronize, reopened ] + types: [opened, synchronize, reopened] + paths-ignore: + - .github/** env: CRATE_NAME: iggy From 85351ec88ef76cf47b8e2026255baeb90b398b96 Mon Sep 17 00:00:00 2001 From: Tchoupinax Date: Sun, 15 Dec 2024 22:08:50 +0100 Subject: [PATCH 3/6] ci: use master as main branch --- .../{main-update-labels.yaml => master-update-labels.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{main-update-labels.yaml => master-update-labels.yaml} (93%) diff --git a/.github/workflows/main-update-labels.yaml b/.github/workflows/master-update-labels.yaml similarity index 93% rename from .github/workflows/main-update-labels.yaml rename to .github/workflows/master-update-labels.yaml index 64254bb5a..4704c222b 100644 --- a/.github/workflows/main-update-labels.yaml +++ b/.github/workflows/master-update-labels.yaml @@ -2,7 +2,7 @@ name: Update repository labels on: push: branches: - - main + - master paths: - ".github/workflows/uptdate-label.yml" - ".github/update-labels.sh" From 1885011ce87e2b5e3b315795be8e88dfeb9dbd0e Mon Sep 17 00:00:00 2001 From: Tchoupinax Date: Sun, 15 Dec 2024 22:51:03 +0100 Subject: [PATCH 4/6] ci: remove outdated rule --- .github/workflows/sanity.yml | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index 359dddde1..ff4352251 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -68,33 +68,12 @@ jobs: - name: Check subject line length uses: gsactions/commit-message-checker@v2 with: - excludeDescription: 'false' # exclude description body of a pull request - excludeTitle: 'false' # exclude the title of a pull request - checkAllCommitMessages: 'false' # checks all commits associated with the pull request + excludeDescription: "false" # exclude description body of a pull request + excludeTitle: "false" # exclude the title of a pull request + checkAllCommitMessages: "false" # checks all commits associated with the pull request accessToken: ${{ secrets.GITHUB_TOKEN }} # needed only when checkAllCommitMessages is true pattern: '^.{0,80}(\n.*)*$' - error: 'Subject of all commits in the PR and PR body/title has to be shorter than 80 characters.' - - - name: Disallow specific prefixes in title - uses: gsactions/commit-message-checker@v2 - with: - excludeDescription: 'true' - excludeTitle: 'true' - checkAllCommitMessages: 'true' - accessToken: ${{ secrets.GITHUB_TOKEN }} - pattern: '^(?!(.*(feat|fix|docs|style|refactor|perf|test|chore):.*(\n.*)*$)).*' - error: 'Do not use prefixes like "feat:", "fix:", etc., in the subject of any commit in the PR.' - - - name: Disallow lowercase subject - uses: gsactions/commit-message-checker@v2 - with: - excludeDescription: 'true' - excludeTitle: 'false' - checkAllCommitMessages: 'false' - accessToken: ${{ secrets.GITHUB_TOKEN }} - pattern: '^[A-Z].*(\n.*)*$' - error: 'Subject of title in the PR has to start with a capital letter.' - + error: "Subject of all commits in the PR and PR body/title has to be shorter than 80 characters." # Uncomment this when we have a proper release - 1.0.0 # semver-checks: # name: SemVer SDK From 179af512da39003312572eec5122ad213b876fd8 Mon Sep 17 00:00:00 2001 From: Tchoupinax Date: Tue, 17 Dec 2024 14:50:54 +0100 Subject: [PATCH 5/6] Revert ignore path --- .github/workflows/test_pr.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test_pr.yml b/.github/workflows/test_pr.yml index 2d4c59480..35d9f670c 100644 --- a/.github/workflows/test_pr.yml +++ b/.github/workflows/test_pr.yml @@ -13,8 +13,6 @@ on: branches: - master types: [opened, synchronize, reopened] - paths-ignore: - - .github/** env: CRATE_NAME: iggy From d32f2aa47da81b0c31cbd8721b0e873757203502 Mon Sep 17 00:00:00 2001 From: Tchoupinax Date: Wed, 1 Jan 2025 17:49:45 +0100 Subject: [PATCH 6/6] Transform title to lowercase --- .github/workflows/pull-request-relabelling.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request-relabelling.yaml b/.github/workflows/pull-request-relabelling.yaml index 43c158658..363556345 100644 --- a/.github/workflows/pull-request-relabelling.yaml +++ b/.github/workflows/pull-request-relabelling.yaml @@ -1,10 +1,10 @@ -name: Relabelling +name: relabelling on: pull_request: jobs: check-labels: - name: Relabelling + name: relabelling runs-on: ubuntu-latest permissions: pull-requests: write