From 9fccb0edb2085bc160a087baabbc4a75f352402e Mon Sep 17 00:00:00 2001 From: Chad <36685920+chadbrokaw@users.noreply.github.com> Date: Fri, 3 Jan 2025 11:37:54 -0700 Subject: [PATCH] test: DAH-2084 Implement Github Actions (#2467) * test: PR Title linter * improvements * add linter to template * translations action * Improvments * Test change * Test change on tl * run grunt translations * ignore whitespace * Test change * revert * zh test change * revert zh change * run on pull request --- .github/PULL_REQUEST_TEMPLATE.md | 4 +- .github/workflows/pr-title-check.yml | 47 +++++++++++++++++++++++ .github/workflows/translations-check.yml | 49 ++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-title-check.yml create mode 100644 .github/workflows/translations-check.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8ef194855f..4d5064214d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -12,7 +12,7 @@ https://sfgovdt.jira.com/browse/ - [ ] branch name begins with `angular` if it contains updates to Angular code - [ ] branch name contains the Jira ticket number -- [ ] PR name follows `type: TICKET-NUMBER Description` format, e.g. `feat: DAH-123 New Feature` +- [ ] PR name follows `type: TICKET-NUMBER Description` format, e.g. `feat: DAH-123 New Feature`. If the PR is urgent and does not need a ticket then use the format `urgent: Description` ### Code quality @@ -32,4 +32,4 @@ https://sfgovdt.jira.com/browse/ - [ ] PR has `needs review` label - [ ] Use `Housing Eng` group to automatically assign reviewers, and/or assign specific engineers -- [ ] If time sensitive, notify engineers in Slack \ No newline at end of file +- [ ] If time sensitive, notify engineers in Slack diff --git a/.github/workflows/pr-title-check.yml b/.github/workflows/pr-title-check.yml new file mode 100644 index 0000000000..2ef976338a --- /dev/null +++ b/.github/workflows/pr-title-check.yml @@ -0,0 +1,47 @@ +name: Validate PR Title + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + check-title: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Validate PR title + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + # Define the regex for the required formats + jira_regex="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test): DAH-[0-9]+ .+" + urgent_regex="^urgent: \S+" + + if [[ "${PR_TITLE}" =~ $urgent_regex ]]; then + echo "PR title contains 'urgent'. Skipping JIRA check but validating description." + elif [[ "${PR_TITLE}" =~ $jira_regex ]]; then + echo "PR title matches JIRA format." + exit 0 + else + echo "Invalid PR title: '${PR_TITLE}'" + echo "Please format your PR title as:" + echo "'