Skip to content

Commit

Permalink
[#11564] Linting should be skipped forgenerated files during local bu…
Browse files Browse the repository at this point in the history
…ildand test (#11910)

* Fix lint:css issue

* Update lint:spaces to ignore build files

* Update linting to use git diff

* update linting routine to be ran as pre-commit hook

* improve linting on github actions

* modify git diff command to work on github actions

* add fetch-depth flag to actions/checkout

* remove trailing space

* remove pre-commit hook

Co-authored-by: Nicolas Chang Weng Yew <[email protected]>
Co-authored-by: Zhao Jingjing <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2022
1 parent 6d8542e commit 6b93611
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 22 deletions.
54 changes: 36 additions & 18 deletions .github/workflows/component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: Component Tests
on:
push:
branches:
- master
- master
- release
pull_request:
branches:
- master
- master
- release
schedule:
- cron: "0 0 * * *" #end of every day
Expand All @@ -16,10 +16,12 @@ jobs:
strategy:
fail-fast: false #ensure both tests run even if one fails
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
Expand All @@ -33,17 +35,33 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Run Backend Linting
run: ./gradlew lint --continue
- name: Cache eslint
uses: actions/cache@v2
with:
path: |
./.eslintcache
key: ${{ runner.os }}-eslint-${{ hashFiles('.eslintcache') }}
restore-keys: |
${{ runner.os }}-eslint-
- name: Cache stylelint
uses: actions/cache@v2
with:
path: |
./.stylelintcache
key: ${{ runner.os }}-stylelint-${{ hashFiles('.stylelintcache') }}
restore-keys: |
${{ runner.os }}-stylelint-
- name: Run Backend Linting
run: ./gradlew lint --continue
- name: Install Frontend Dependencies
run: npm ci
- name: Run Lint Checks
run: npm run lint
run: npm ci
- name: Run Lint Checks
run: npm run lint
component-testing:
strategy:
fail-fast: false #ensure both tests run even if one fails
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -60,21 +78,21 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Update Property File
- name: Update Property File
run: mv src/test/resources/test.ci-${{ matrix.os }}.properties src/test/resources/test.properties
- name: Run Solr search service
if: matrix.os == 'ubuntu-latest' # Docker does not work well on Windows env
run: docker-compose run -d -p 8983:8983 solr
- name: Run Backend Tests
run: |
./gradlew createConfigs componentTests
./gradlew createConfigs componentTests
./gradlew jacocoReport
- name: Generate Types
- name: Generate Types
run: ./gradlew generateTypes
- name: Install Frontend Dependencies
run: npm ci
- name: Run Frontend Tests
run: npm run coverage
- name: Upload to Codecov
if: matrix.os == 'ubuntu-latest' #only upload to codecov on ubuntu VM
- name: Install Frontend Dependencies
run: npm ci
- name: Run Frontend Tests
run: npm run coverage
- name: Upload to Codecov
if: matrix.os == 'ubuntu-latest' #only upload to codecov on ubuntu VM
uses: codecov/codecov-action@v3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
node_modules/
npm-debug.log
coverage/*
.eslintcache
.stylelintcache

# Gradle
.gradle
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
"analyze": "webpack-bundle-analyzer src/web/dist/stats.json",
"test": "ng test --watch",
"coverage": "rimraf coverage && ng test --coverage",
"lint:ts": "ng lint --eslint-config static-analysis/teammates-eslint.yml",
"lint:css": "stylelint \"src/web/**/*.css\" \"src/web/**/*.scss\" \"src/web/**/*.html\" --config static-analysis/teammates-stylelint.yml",
"lint:spaces": "lintspaces -n -t -d spaces -l 1 -. \"src/main/**/*.html\" \"src/web/**/*.html\" \"src/**/*.xml\" \"src/**/*.json\" \"src/**/*.properties\" \"*.yml\" \"*.json\" \"*.gradle\" \"static-analysis/*.*ml\" \".gitattributes\"",
"lint": "npm-run-all lint:* -c"
"lint:ts": "ng lint --cache --eslint-config static-analysis/teammates-eslint.yml",
"lint:css": "stylelint \"src/web/**/*.css\" \"src/web/**/*.scss\" \"src/web/**/*.html\" --ignore-pattern \"src/web/dist/*.css\" --cache --config static-analysis/teammates-stylelint.yml",
"lint:windows:spaces": "lintspaces -n -t -d spaces -l 1 -. \"src/main/**/*.html\" \"src/web/**/*.html\" \"src/**/*.xml\" \"src/**/*.json\" \"src/**/*.properties\" \"*.yml\" \"*.json\" \"*.gradle\" \"static-analysis/*.*ml\" \".gitattributes\"",
"lint:nix:spaces": "lintspaces -n -t -d spaces -l 1 --matchdotfiles $(git diff --name-only --diff-filter=ACMRTUXB origin/master HEAD | grep -E \"src/(main|web)/.*.html|src/.*.(xml|json|properties)|*.(yml|json|gradle)|static-analysis/*.*ml|.gitattributes\")",
"lint": "run-script-os",
"lint:windows": "npm-run-all lint:ts lint:css lint:windows:spaces -c",
"lint:nix": "npm-run-all lint:ts lint:css lint:nix:spaces -c"
},
"private": true,
"dependencies": {
Expand Down Expand Up @@ -71,6 +74,7 @@
"npm-run-all": "^4.1.5",
"postcss": "^8.4.7",
"rimraf": "^3.0.2",
"run-script-os": "^1.1.6",
"stylelint": "^13.13.1",
"stylelint-config-standard": "^22.0.0",
"typescript": "~4.3.5",
Expand Down

0 comments on commit 6b93611

Please sign in to comment.