-
Notifications
You must be signed in to change notification settings - Fork 186
50 lines (45 loc) · 1.93 KB
/
eslint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# ESLint is a tool for identifying and reporting on patterns
# found in ECMAScript/JavaScript code.
# More details at https://github.com/eslint/eslint
# and https://eslint.org
name: ESLint
on:
pull_request:
jobs:
linter:
name: Ensure the code format on the changed files
runs-on: ubuntu-latest
steps:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
- name: Checkout code
uses: actions/checkout@v3
# - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Verify the changed files
run: |
REMOTE_NAME=origin
echo "Base ref: $GITHUB_BASE_REF"
echo "Head ref: $GITHUB_HEAD_REF"
echo "Fetching branch: $GITHUB_BASE_REF"
git fetch origin $GITHUB_BASE_REF
echo "Fetching branch: $GITHUB_HEAD_REF"
git fetch origin $GITHUB_HEAD_REF
echo "Listing branches"
git branch -a
echo "Getting diff files ignoring deleted and getting the changed or renamed files"
CHANGED_FILES=$(git diff --name-status --diff-filter d ${REMOTE_NAME}/${GITHUB_BASE_REF}..${REMOTE_NAME}/${GITHUB_HEAD_REF} | awk '{print $2}')
echo "Changed files:"
echo "${CHANGED_FILES}"
git checkout $GITHUB_HEAD_REF
plugin_package_json=$(ls -d plugins/* | head -n1)
echo "Installing dependencies from plugin: ${plugin_package_json}"
yarn --cwd "${plugin_package_json}" --modules-folder ../../node_modules
echo "Running eslint on the changed files"
npx eslint ${CHANGED_FILES}