From 339cda44635002361415fbf060065051133770e5 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Mon, 11 Dec 2023 10:55:30 +0100 Subject: [PATCH] CI: Add linting jobs (#643) * lint: Add linting command to package.json * ci: Add linting step to GitHub Actions workflow * refactor: Rename test to CI & minor formatting * ci: Also configure backend linting * deps: Add flake8 to dev requirements * ci: Add names to test jobs * ci: Add continue-on-error flag to backend-lint job --- .github/workflows/ci.yml | 38 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 19 ------------------ backend/requirements/dev.txt | 2 ++ frontend/package.json | 3 ++- 4 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..c4151bda1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: Test suite + +on: + push: + +jobs: + + backend-test: + name: Test Backend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run Backend Tests + run: sudo docker-compose --env-file .env-github-actions run server bash -c "python manage.py test" + + backend-lint: + name: Lint Backend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Lint Backend + continue-on-error: true + run: sudo docker-compose --env-file .env-github-actions run server bash -c "flake8" + + frontend-test: + name: Test Frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run Frontend Tests + run: sudo docker-compose --env-file .env-github-actions run client yarn test --watchAll=false + + frontend-lint: + name: Lint Frontend + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: sudo docker-compose --env-file .env-github-actions run client yarn lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index c740293c7..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Test suite - -on: - push: - -jobs: - backend-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Run Backend Tests - run: sudo docker-compose --env-file .env-github-actions run server bash -c "python manage.py test" - - frontend-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Run Frontend Tests - run: sudo docker-compose --env-file .env-github-actions run client yarn test --watchAll=false diff --git a/backend/requirements/dev.txt b/backend/requirements/dev.txt index caf4f14c7..175c085da 100644 --- a/backend/requirements/dev.txt +++ b/backend/requirements/dev.txt @@ -28,6 +28,8 @@ django-debug-toolbar==3.2.2 # via -r requirements.in/dev.txt django-inline-actions==2.4.0 # via -r requirements.in/base.txt +flake8==4.0.1 + # via -r requirements.in/dev.txt idna==3.3 # via requests iptocc==2.1.2 diff --git a/frontend/package.json b/frontend/package.json index e694b60fb..ba3456fe1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -33,7 +33,8 @@ "scss-watch": "sass src/index.scss src/index.css; sass --watch src/index.scss src/index.css", "storybook": "REACT_APP_API_ROOT=http://localhost:8000 && storybook dev -p 6006", "storybook:build": "storybook build", - "lint": "eslint . --ext .js,.jsx,.ts,.tsx" + "lint:ts": "eslint . --ext .js,.jsx,.ts,.tsx", + "lint": "eslint src/**/*.js" }, "eslintConfig": { "extends": [