2021-01-06 15:37:59 -05:00
|
|
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2020-11-22 15:50:07 -05:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
name: Frontend / Lint
|
2020-08-31 06:48:58 -04:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2022-11-11 04:55:08 -05:00
|
|
|
branches: [ develop ]
|
2020-08-31 06:48:58 -04:00
|
|
|
pull_request:
|
2022-11-11 04:55:08 -05:00
|
|
|
branches: [ develop ]
|
2022-10-21 12:57:29 -04:00
|
|
|
|
|
|
|
env:
|
|
|
|
NODE_VERSION: 18
|
2020-08-31 06:48:58 -04:00
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: frontend
|
|
|
|
|
2020-08-31 06:48:58 -04:00
|
|
|
jobs:
|
2022-11-11 04:55:08 -05:00
|
|
|
changes:
|
|
|
|
name: Check for frontend changes
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
pull-requests: read
|
|
|
|
outputs:
|
2022-11-21 11:24:36 -05:00
|
|
|
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
|
2022-11-11 04:55:08 -05:00
|
|
|
steps:
|
2022-11-20 16:16:54 -05:00
|
|
|
- uses: actions/checkout@v3
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
|
|
|
|
2022-11-11 04:55:08 -05:00
|
|
|
- name: Check for frontend file changes
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
2022-11-11 04:55:08 -05:00
|
|
|
uses: dorny/paths-filter@v2
|
|
|
|
id: changed
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
files:
|
|
|
|
- 'frontend/**'
|
|
|
|
- '.github/**'
|
|
|
|
- '.yarn/**'
|
|
|
|
|
2020-08-31 06:48:58 -04:00
|
|
|
lint:
|
2022-11-11 04:55:08 -05:00
|
|
|
needs: changes
|
2020-08-31 06:48:58 -04:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Lints all .ts and .tsx files
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-03-05 10:27:37 -05:00
|
|
|
uses: actions/checkout@v3
|
2020-11-29 04:07:44 -05:00
|
|
|
|
|
|
|
- name: Get yarn cache directory path
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2020-11-29 04:07:44 -05:00
|
|
|
id: yarn-cache-dir-path
|
2022-10-19 16:47:03 -04:00
|
|
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
2020-11-29 04:07:44 -05:00
|
|
|
|
2021-06-21 16:58:54 -04:00
|
|
|
- name: Cache yarn cache
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-04-02 05:07:13 -04:00
|
|
|
uses: actions/cache@v3
|
2020-11-29 04:07:44 -05:00
|
|
|
id: yarn-cache
|
2020-08-31 06:48:58 -04:00
|
|
|
with:
|
2020-11-29 04:07:44 -05:00
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
2022-11-11 04:55:08 -05:00
|
|
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
|
2020-11-29 04:07:44 -05:00
|
|
|
restore-keys: |
|
2022-10-21 12:57:29 -04:00
|
|
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
2020-11-29 04:07:44 -05:00
|
|
|
|
2020-08-31 06:48:58 -04:00
|
|
|
- name: Set up NodeJS
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-02-25 19:36:32 -05:00
|
|
|
uses: actions/setup-node@v3
|
2020-08-31 06:48:58 -04:00
|
|
|
with:
|
2022-10-21 12:57:29 -04:00
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
2022-11-11 04:55:08 -05:00
|
|
|
cache-dependency-path: frontend/yarn.lock
|
|
|
|
cache: 'yarn'
|
2021-06-06 17:14:00 -04:00
|
|
|
|
|
|
|
- name: Install dependencies
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2021-12-30 12:45:04 -05:00
|
|
|
run: yarn install --immutable
|
2022-07-02 10:46:43 -04:00
|
|
|
|
2021-06-06 17:14:00 -04:00
|
|
|
- name: Lint code
|
2022-11-11 04:55:08 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-07-02 10:46:43 -04:00
|
|
|
run: yarn lint
|