Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reusable workflows structure, RW pre-commit, RW DangerJS, RW Sync Jira (3pack) #20

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# install with: 'pre-commit install --config=.github/.pre-commit-config.yaml'

minimum_pre_commit_version: 3.3.0
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [commit]

repos:
- repo: meta
hooks:
- id: check-hooks-apply

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-case-conflict
- id: mixed-line-ending
args: ['-f=lf']

- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.10.0
hooks:
- id: conventional-precommit-linter

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ['--write-changes']
additional_dependencies: [tomli]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
args: [--number]
additional_dependencies:
- mdformat-gfm
- mdformat-ruff
- mdformat-simple-breaks

- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args:
- --base64-limit=4
- --hex-limit=3
132 changes: 132 additions & 0 deletions .github/workflows/reusable-dangerjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
# Reusable workflow in "espressif/.github" repository (Organization level)
name: DangerJS (PR style linter)

on:
workflow_call:
inputs:
ref:
description: 'The pull request head reference'
required: true
type: string
rule-description:
description: 'Enable rule for PR Description'
required: false
type: string
default: 'true'
rule-commit-messages:
description: 'Enable rule for PR Lint Commit Messages'
required: false
type: string
default: 'true'
rule-size-lines:
description: 'Enable rule for PR Size (changed lines)'
required: false
type: string
default: 'true'
rule-source-branch:
description: 'Enable rule for PR Source branch name'
required: false
type: string
default: 'true'
rule-target-branch:
description: 'Enable rule for PR Target branch name'
required: false
type: string
default: 'true'
rule-max-commits:
description: 'Enable rule for PR Too Many Commits'
required: false
type: string
default: 'true'
commit-messages-types:
description: 'Allowed commit message "Type"s'
required: false
type: string
default: 'change,ci,docs,feat,fix,refactor,remove,revert,test'
commit-messages-max-body-line-length:
description: 'Max length for commit message "Body" line'
required: false
type: string
default: '100'
commit-messages-max-summary-length:
description: 'Max length for commit message "Summary"'
required: false
type: string
default: '72'
commit-messages-min-summary-length:
description: 'Min length for commit message "Summary"'
required: false
type: string
default: '20'
description-ignore-sections:
description: 'Sections of PR description to ignore when counting length'
required: false
type: string
default: 'related,release,breaking'
max-size-lines:
description: 'Max changed code lines in PR'
required: false
type: string
default: '1000'
max-commits-info:
description: 'Soft limit for maximum commits in PR'
required: false
type: string
default: '2'
max-commits-warn:
description: 'Hard limit for maximum commits in PR'
required: false
type: string
default: '5'
instructions-contributions-file:
description: 'Path to CONTRIBUTING.md or other instructions file'
required: false
type: string
default: ''
instructions-gitlab-mirror:
description: 'Enable GitLab mirror instructions'
required: false
type: string
default: 'false'
instructions-cla-link:
description: 'Link to CLA (Contributor License Agreement)'
required: false
type: string
default: ''

permissions:
pull-requests: write
contents: write

jobs:
dangerjs:
runs-on: ubuntu-latest
steps:
- name: Check out Pull Request head
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- name: DangerJS (PR style linter)
uses: espressif/shared-github-dangerjs@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
rule-description: ${{ inputs.rule-description }}
rule-commit-messages: ${{ inputs.rule-commit-messages }}
rule-size-lines: ${{ inputs.rule-size-lines }}
rule-source-branch: ${{ inputs.rule-source-branch }}
rule-target-branch: ${{ inputs.rule-target-branch }}
rule-max-commits: ${{ inputs.rule-max-commits }}
commit-messages-types: ${{ inputs.commit-messages-types }}
commit-messages-max-body-line-length: ${{ inputs.commit-messages-max-body-line-length }}
commit-messages-max-summary-length: ${{ inputs.commit-messages-max-summary-length }}
commit-messages-min-summary-length: ${{ inputs.commit-messages-min-summary-length }}
description-ignore-sections: ${{ inputs.description-ignore-sections }}
max-size-lines: ${{ inputs.max-size-lines }}
max-commits-info: ${{ inputs.max-commits-info }}
max-commits-warn: ${{ inputs.max-commits-warn }}
instructions-contributions-file: ${{ inputs.instructions-contributions-file }}
instructions-gitlab-mirror: ${{ inputs.instructions-gitlab-mirror }}
instructions-cla-link: ${{ inputs.instructions-cla-link }}
34 changes: 34 additions & 0 deletions .github/workflows/reusable-pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
# Reusable workflow in "espressif/.github" repository (Organization level)
name: Pre-commit (PR code changes)

on:
workflow_call:
inputs:
python-version:
description: 'The Python version to use in CI'
required: false
type: string
default: '3.9'
skip:
description: "The pre-commit hooks to skip in CI"
required: false
type: string
default: 'pip-compile'

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Run pre-commit
uses: pre-commit/[email protected]
env:
SKIP: ${{ inputs.skip }}
33 changes: 33 additions & 0 deletions .github/workflows/reusable-sync-jira-issue-comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Reusable workflow in "espressif/.github" repository (Organization level)
name: Sync JIRA - Issue Comments

on:
workflow_call:
inputs:
jira-project:
description: 'Jira project name'
required: true
type: string

jira-component:
description: 'Jira component name'
required: false
type: string
default: 'GitHub'

jobs:
sync_issue_comments_to_jira:
name: Sync Issue Comments to Jira
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Sync issue comments to JIRA
uses: espressif/sync-jira-actions@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JIRA_PASS: ${{ secrets.JIRA_PASS }}
JIRA_PROJECT: ${{ inputs.jira-project }}
JIRA_COMPONENT: ${{ inputs.jira-component }}
JIRA_URL: ${{ secrets.JIRA_URL }}
JIRA_USER: ${{ secrets.JIRA_USER }}
33 changes: 33 additions & 0 deletions .github/workflows/reusable-sync-jira-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Reusable workflow in "espressif/.github" repository (Organization level)
name: Sync JIRA - Issues

on:
workflow_call:
inputs:
jira-project:
description: 'Jira project name'
required: true
type: string

jira-component:
description: 'Jira component name'
required: false
type: string
default: 'GitHub'

jobs:
sync-jira-issues:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Sync JIRA - Issues
uses: espressif/sync-jira-actions@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JIRA_PASS: ${{ secrets.JIRA_PASS }}
JIRA_PROJECT: ${{ inputs.jira-project }}
JIRA_COMPONENT: ${{ inputs.jira-component }}
JIRA_URL: ${{ secrets.JIRA_URL }}
JIRA_USER: ${{ secrets.JIRA_USER }}
41 changes: 41 additions & 0 deletions .github/workflows/reusable-sync-jira-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
# Reusable workflow in "espressif/.github" repository (Organization level)
name: Sync JIRA - Pull Requests

on:
workflow_call:
inputs:
cron-job:
description: 'Run as scheduled job'
required: false
type: boolean
default: true

jira-project:
description: 'Jira project name'
required: true
type: string

jira-component:
description: 'Jira component name'
required: false
type: string
default: 'GitHub'

jobs:
sync-jira-pull-requests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: JIRA Sync - Pull Requests
uses: espressif/sync-jira-actions@v1
with:
cron_job: ${{ inputs.cron-job }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JIRA_PASS: ${{ secrets.JIRA_PASS }}
JIRA_PROJECT: ${{ inputs.jira-project }}
JIRA_COMPONENT: ${{ inputs.jira-component }}
JIRA_URL: ${{ secrets.JIRA_URL }}
JIRA_USER: ${{ secrets.JIRA_USER }}
16 changes: 16 additions & 0 deletions .github/workflows/templates/call-pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copy this file form here to your TARGET PROJECT (e.g. https://github.com/esptool/.github/workflows/call-pre-commit.yml)

# If you have another versions of pre-commit hooks Github Action workflow already in your repo,
# (e.g. https://github.com/esptool/.github/workflows/pre-commit.yml) you should remove them
# with adding this file to your repo to avoid conflicts and double execution of the same tasks.

# Keep it slim after adding to your repo and remove all absolutely unnecessary comments.
---
name: Pre-commit (PR code changes)

on:
pull_request:

jobs:
call-pre-commit:
uses: espressif/.github/.github/workflows/reusable-pre-commit.yml@main
Loading