mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-24 05:26:42 +02:00
chore: Add check-pr.yml github workflow (#609)
This commit is contained in:
parent
a8f870304a
commit
42880607b4
2 changed files with 90 additions and 4 deletions
86
.github/workflows/check-pr.yml
vendored
Normal file
86
.github/workflows/check-pr.yml
vendored
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
name: Check Pull Requests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- edited
|
||||||
|
- synchronize
|
||||||
|
- labeled
|
||||||
|
- unlabeled
|
||||||
|
merge_group:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-title:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check PR title
|
||||||
|
if: github.event_name == 'pull_request_target'
|
||||||
|
uses: amannn/action-semantic-pull-request@v5
|
||||||
|
id: check_pr_title
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
# Add comment indicating we require pull request titles to follow conventional commits specification
|
||||||
|
- uses: marocchino/sticky-pull-request-comment@v2
|
||||||
|
if: always() && (steps.check_pr_title.outputs.error_message != null)
|
||||||
|
with:
|
||||||
|
header: pr-title-lint-error
|
||||||
|
message: |
|
||||||
|
Thank you for opening this pull request!
|
||||||
|
|
||||||
|
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
|
||||||
|
|
||||||
|
Details:
|
||||||
|
|
||||||
|
> ${{ steps.check_pr_title.outputs.error_message }}
|
||||||
|
|
||||||
|
# Delete a previous comment when the issue has been resolved
|
||||||
|
- if: ${{ steps.check_pr_title.outputs.error_message == null }}
|
||||||
|
uses: marocchino/sticky-pull-request-comment@v2
|
||||||
|
with:
|
||||||
|
header: pr-title-lint-error
|
||||||
|
delete: true
|
||||||
|
|
||||||
|
check-breaking-change-label:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
# use an environment variable to pass untrusted input to the script
|
||||||
|
# see https://securitylab.github.com/research/github-actions-untrusted-input/
|
||||||
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||||
|
steps:
|
||||||
|
- name: Check breaking change label
|
||||||
|
id: check_breaking_change
|
||||||
|
run: |
|
||||||
|
pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!:'
|
||||||
|
# Check if pattern matches
|
||||||
|
if echo "${PR_TITLE}" | grep -qE "$pattern"; then
|
||||||
|
echo "breaking_change=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "breaking_change=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
- name: Add label
|
||||||
|
if: steps.check_breaking_change.outputs.breaking_change == 'true'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
script: |
|
||||||
|
github.rest.issues.addLabels({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
labels: ['Type: Breaking Change']
|
||||||
|
})
|
||||||
|
|
||||||
|
do-not-merge:
|
||||||
|
if: ${{ contains(github.event.*.labels.*.name, 'do not merge') }}
|
||||||
|
name: Prevent Merging
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check for label
|
||||||
|
run: |
|
||||||
|
echo "Pull request is labeled as 'do not merge'"
|
||||||
|
echo "This workflow fails so that the pull request cannot be merged"
|
||||||
|
exit 1
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -45,15 +45,15 @@ jobs:
|
||||||
TASKRC: taskwarrior-testdata/.taskrc
|
TASKRC: taskwarrior-testdata/.taskrc
|
||||||
TASKDATA: taskwarrior-testdata/.task
|
TASKDATA: taskwarrior-testdata/.task
|
||||||
RUST_BACKTRACE: full
|
RUST_BACKTRACE: full
|
||||||
|
|
||||||
|
|
||||||
generate_coverage:
|
generate_coverage:
|
||||||
uses: ./.github/workflows/generate_coverage.yml
|
uses: ./.github/workflows/generate_coverage.yml
|
||||||
# Avoid double-compiling taskwarrior if not cached, or wasting CI time if tests fail
|
# Avoid double-compiling taskwarrior if not cached, or wasting CI time if tests fail
|
||||||
needs: test
|
needs: test
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
name: Rustfm
|
name: Rustfmt
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
@ -80,4 +80,4 @@ jobs:
|
||||||
- uses: clechasseur/rs-cargo@v2
|
- uses: clechasseur/rs-cargo@v2
|
||||||
with:
|
with:
|
||||||
command: clippy
|
command: clippy
|
||||||
args: -- -D warnings
|
args: -- -D warnings
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue