diff --git a/.github/workflows/branch-name-check.yml b/.github/workflows/branch-name-check.yml new file mode 100644 index 0000000..4f2612c --- /dev/null +++ b/.github/workflows/branch-name-check.yml @@ -0,0 +1,61 @@ +name: Branch Name Check + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + branches: + - main + - dev + - 'client-*' + +jobs: + check-branch-name: + runs-on: ubuntu-latest + steps: + - name: Check branch name for main + if: github.base_ref == 'main' + run: | + BRANCH_NAME="${{ github.head_ref }}" + echo "Source branch: $BRANCH_NAME" + echo "Target branch: ${{ github.base_ref }}" + + if [[ $BRANCH_NAME == dev ]] || [[ $BRANCH_NAME == hotfix-* ]]; then + echo "Branch name is valid" + exit 0 + else + echo "Invalid branch name for main pull request" + echo "Branch name must be dev or start with 'hotfix-'" + exit 1 + fi + + - name: Check branch name for dev + if: github.base_ref == 'dev' + run: | + BRANCH_NAME="${{ github.head_ref }}" + echo "Source branch: $BRANCH_NAME" + echo "Target branch: ${{ github.base_ref }}" + + if [[ $BRANCH_NAME == hotfix-* ]] || [[ $BRANCH_NAME == feature-* ]] || [[ $BRANCH_NAME == bugfix-* ]]; then + echo "Branch name is valid" + exit 0 + else + echo "Invalid branch name for dev pull request" + echo "Branch name must start with 'hotfix-', 'feature-', or 'bugfix-'" + exit 1 + fi + + - name: Check branch name for client branches + if: startsWith(github.base_ref, 'client-') + run: | + BRANCH_NAME="${{ github.head_ref }}" + echo "Source branch: $BRANCH_NAME" + echo "Target branch: ${{ github.base_ref }}" + + if [[ $BRANCH_NAME == feature-* ]] || [[ $BRANCH_NAME == bugfix-* ]] || [[ $BRANCH_NAME == hotfix-* ]]; then + echo "Branch name is valid" + exit 0 + else + echo "Invalid branch name for client pull request" + echo "Branch name must start with 'feature-', 'bugfix-', or 'hotfix-'" + exit 1 + fi \ No newline at end of file diff --git a/README.md b/README.md index 9c726c0..6b306c3 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ This repo stores the following shared repository settings/configurations/templat - `isort` - `pylint` - `codecov` + - `mypy` - Shared configurations for Azure Pipelines - Shared configurations for GitHub Actions - Issue/PR labels shared across the organization diff --git a/azure/README.md b/azure/README.md index cda1b47..32c5aed 100644 --- a/azure/README.md +++ b/azure/README.md @@ -27,11 +27,12 @@ The templates are organized into the following files: | `COVERAGE` | boolean | `false` | Flag to report test coverage to `codecov` | | `TIMEOUT_STYLE` | number | `10` | Runtime allowed for each style check, in minutes | | `IGNORE_STYLE` | boolean | `false` | Flag to allow `formatting and linting` checks to fail without failing the pipeline | -| `BASE_FORMAT_AND_LINT` | boolean | `false` | Flag to trigger the `base_format_and_lint` check | +| `BASE_FORMAT_AND_LINT` | boolean | `true` | Flag to trigger the `base_format_and_lint` check | | `ISORT` | boolean | `false` | Flag to trigger the `isort` check | | `PYLINT` | boolean | `false` | Flag to trigger the `pylint` check | | `CLANG_FORMAT` | boolean | `false` | Flag to trigger the `clang-format` check | | `FPRETTIFY` | boolean | `false` | Flag to trigger the `fprettify` check | +| `MYPY` | boolean | `false` | Flag to trigger the `mypy` check | | `TAPENADE` | boolean | `false` | Flag to trigger the Tapenade check | | `TIMEOUT_TAPENADE` | number | `10` | Runtime allowed for the Tapenade check, in minutes | | `TAPENADE_SCRIPT` | string | `.github/build_tapenade.sh` | Path to Bash script with commands to run Tapenade | diff --git a/azure/azure_style.yaml b/azure/azure_style.yaml index 210017f..2236365 100644 --- a/azure/azure_style.yaml +++ b/azure/azure_style.yaml @@ -23,6 +23,9 @@ parameters: - name: FPRETTIFY type: boolean default: false + - name: MYPY + type: boolean + default: false jobs: - job: base_format_and_lint pool: @@ -153,4 +156,25 @@ jobs: # Exit with an error if any of the tracked files changed git diff --summary --exit-code + - job: mypy + pool: + vmImage: "ubuntu-22.04" + timeoutInMinutes: ${{ parameters.TIMEOUT }} + continueOnError: ${{ parameters.IGNORE_STYLE }} + condition: ${{ parameters.MYPY }} + steps: + - checkout: self + - checkout: azure_template + - task: UsePythonVersion@0 + inputs: + versionSpec: "3.11" + - script: | + cd ${{ parameters.REPO_NAME }} + + pip install wheel + pip install mypy + + # Run mypy check (should pick up local config from mypy.ini or .mypy.ini if present) + mypy + diff --git a/azure/azure_template.yaml b/azure/azure_template.yaml index 4a3bb66..76e21f5 100644 --- a/azure/azure_template.yaml +++ b/azure/azure_template.yaml @@ -42,6 +42,9 @@ parameters: - name: IGNORE_STYLE type: boolean default: false + - name: BASE_FORMAT_AND_LINT + type: boolean + default: true - name: ISORT type: boolean default: false @@ -54,7 +57,7 @@ parameters: - name: FPRETTIFY type: boolean default: false - - name: RUFF + - name: MYPY type: boolean default: false # Tapenade @@ -115,10 +118,12 @@ stages: REPO_NAME: ${{ parameters.REPO_NAME }} TIMEOUT: ${{ parameters.TIMEOUT_STYLE }} IGNORE_STYLE: ${{ parameters.IGNORE_STYLE }} + BASE_FORMAT_AND_LINT: ${{ parameters.BASE_FORMAT_AND_LINT }} ISORT: ${{ parameters.ISORT }} PYLINT: ${{ parameters.PYLINT }} CLANG_FORMAT: ${{ parameters.CLANG_FORMAT }} FPRETTIFY: ${{ parameters.FPRETTIFY }} + MYPY: ${{ parameters.MYPY }} - stage: Tapenade dependsOn: []