diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 3f8ae99..fa11570 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -3,10 +3,8 @@ name: Build and Deploy Sites on: push: branches: - - 'main' + - main pull_request: - branches: - - 'main' env: RUNNER_TOOL_CACHE: /toolcache diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml new file mode 100644 index 0000000..5463402 --- /dev/null +++ b/.github/workflows/lint-and-test.yml @@ -0,0 +1,26 @@ +name: Lint and Test + +on: + push: + branches: + - main + pull_request: + +env: + RUNNER_TOOL_CACHE: /toolcache + +jobs: + lint_and_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: npm ci + + - name: Run linting + run: npm run lint:nofix diff --git a/package.json b/package.json index 5b89e3a..a09d4f4 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,10 @@ }, "scripts": { "surge": "./node_modules/.bin/surge", - "lint": "eslint '*/_assets/scripts/**/*.js'", - "prettier": "prettier '*/_assets/scripts/**/*.js' --write", + "lint": "eslint --fix '*/_assets/scripts/**/*.js' && npm run prettier:write", + "lint:nofix": "eslint '*/_assets/scripts/**/*.js' && npm run prettier", + "prettier": "prettier '*/_assets/scripts/**/*.js' --check", + "prettier:write": "prettier '*/_assets/scripts/**/*.js' --write", "brandonb.ca:deploy:dryrun": "cd brandonb.ca && JEKYLL_ENV=production gulp deploy_dryrun", "brandonb.ca:deploy": "cd brandonb.ca && JEKYLL_ENV=production gulp deploy", "brandonb.ca:start:dev": "cd brandonb.ca && gulp --noserviceworker",