|
| 1 | +# NOTE: This name appears in GitHub's Checks API and in workflow's status badge. |
| 2 | +name: ci-lint |
| 3 | + |
| 4 | +# Trigger the workflow when: |
| 5 | +on: |
| 6 | + # A push occurs to one of the matched branches. |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + - stable/* |
| 11 | + # Or when a pull request event occurs for a pull request against one of the |
| 12 | + # matched branches. |
| 13 | + pull_request: |
| 14 | + branches: |
| 15 | + - master |
| 16 | + - stable/* |
| 17 | + |
| 18 | +jobs: |
| 19 | + lint: |
| 20 | + # NOTE: This name appears in GitHub's Checks API. |
| 21 | + name: lint |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v6 |
| 26 | + with: |
| 27 | + submodules: true |
| 28 | + # Checkout pull request HEAD commit instead of merge commit. |
| 29 | + ref: ${{ github.event.pull_request.head.sha }} |
| 30 | + # Fetch all history so gitlint can check the relevant commits. |
| 31 | + fetch-depth: "0" |
| 32 | + - name: Set up Python 3 |
| 33 | + uses: actions/setup-python@v6 |
| 34 | + with: |
| 35 | + python-version: "3.x" |
| 36 | + - name: Set up Node.js 20 |
| 37 | + uses: actions/setup-node@v6 |
| 38 | + with: |
| 39 | + node-version: "20.x" |
| 40 | + cache: yarn |
| 41 | + - name: Install dependencies |
| 42 | + run: yarn install --frozen-lockfile |
| 43 | + - name: Install gitlint |
| 44 | + run: | |
| 45 | + python -m pip install gitlint |
| 46 | + # Needed for Towncrier fork to work with 3.12 and above |
| 47 | + - name: Install setuptools |
| 48 | + run: | |
| 49 | + python -m pip install setuptools |
| 50 | + - name: Install towncrier |
| 51 | + run: | |
| 52 | + python -m pip install https://github.com/oasisprotocol/towncrier/archive/oasis-master.tar.gz |
| 53 | + - name: Check for presence of a Change Log fragment (only pull requests) |
| 54 | + # NOTE: The pull request' base branch needs to be fetched so towncrier |
| 55 | + # is able to compare the current branch with the base branch. |
| 56 | + # Source: https://github.com/actions/checkout/#fetch-all-branches. |
| 57 | + run: | |
| 58 | + git fetch --no-tags origin "+refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}" |
| 59 | + towncrier check --compare-with "origin/${BASE_BRANCH}" |
| 60 | + env: |
| 61 | + BASE_BRANCH: ${{ github.base_ref }} |
| 62 | + if: github.event_name == 'pull_request' |
| 63 | + - name: Lint documentation |
| 64 | + run: | |
| 65 | + yarn lint-docs |
| 66 | + # Always run this step so that all linting errors can be seen at once. |
| 67 | + if: always() |
| 68 | + - name: Lint Change Log fragments |
| 69 | + run: | |
| 70 | + yarn lint-changelog |
| 71 | + # Always run this step so that all linting errors can be seen at once. |
| 72 | + if: always() |
| 73 | + - name: Lint git commits |
| 74 | + run: | |
| 75 | + yarn lint-git |
| 76 | + # Always run this step so that all linting errors can be seen at once. |
| 77 | + if: always() |
| 78 | + - name: Prettier |
| 79 | + run: yarn prettier-check |
| 80 | + # Always run this step so that all linting errors can be seen at once. |
| 81 | + if: always() |
| 82 | + - name: ESLint |
| 83 | + # Disallow warnings and always throw errors. |
| 84 | + run: yarn lint --max-warnings 0 |
| 85 | + # Always run this step so that all linting errors can be seen at once. |
| 86 | + if: always() |
| 87 | + - name: Validate TypeScript |
| 88 | + run: yarn checkTs |
| 89 | + # Always run this step so that all linting errors can be seen at once. |
| 90 | + if: always() |
0 commit comments