From 237b4d4e5a5a706d644346a1c54d5c10115fc665 Mon Sep 17 00:00:00 2001 From: Sudharaka Palamakumbura Date: Sun, 10 Dec 2023 23:28:59 -0800 Subject: [PATCH] Add CI for better error catching (#3) * feat: add CI * feat: add a seperate action to setup project * fix: correct eslint commands * fix: set updated node versions --- .github/actions/setup-project/action.yml | 24 +++++++++++++ .github/workflows/ci.yml | 44 ++++++++++++++++++++++++ package.json | 9 +++-- 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 .github/actions/setup-project/action.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/actions/setup-project/action.yml b/.github/actions/setup-project/action.yml new file mode 100644 index 0000000..1c30f20 --- /dev/null +++ b/.github/actions/setup-project/action.yml @@ -0,0 +1,24 @@ +name: Setup Project +description: Installs Node.js, NPM and dependencies and sets up the project + +inputs: + DECRYPTION_SECRET: + description: The secret used to decrypt the files + required: true + +runs: + using: 'composite' + steps: + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version-file: 'package.json' + cache: 'npm' + + - name: Install dependencies + shell: bash + run: npm ci --prefer-offline --no-audit --progress=false + + - uses: amplium/git-crypt-action@master + with: + key_encoded: ${{ inputs.DECRYPTION_SECRET }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d703acd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: Continuous Integration + +on: + push: + branches: + - main + pull_request: + types: + - opened + - synchronize + - reopened + +jobs: + lint: + runs-on: ubuntu-latest + + timeout-minutes: 15 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup project + uses: ./.github/actions/setup-project + with: + DECRYPTION_SECRET: ${{ secrets.DECRYPTION_SECRET }} + + - run: npm run eslint:quiet + + prettier: + runs-on: ubuntu-latest + + timeout-minutes: 15 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup project + uses: ./.github/actions/setup-project + with: + DECRYPTION_SECRET: ${{ secrets.DECRYPTION_SECRET }} + + - run: npm run prettier:check diff --git a/package.json b/package.json index 00b7dcb..53721c4 100644 --- a/package.json +++ b/package.json @@ -11,8 +11,8 @@ "puppeteer-extra-plugin-stealth": "^2.11.2" }, "engines": { - "node": "18.x", - "npm": "9.x" + "node": "20.x", + "npm": "10.x" }, "devDependencies": { "eslint": "^8.55.0", @@ -25,7 +25,10 @@ "scripts": { "start-booker": "node add-to-cart.mjs", "start-checker": "node check-for-changes.mjs", + "prettier:check": "prettier --check .", "prettier:write": "prettier --write .", - "eslint:fix": "eslint . --ignore-path .gitignore --ext .mjs,.js --fix" + "eslint": "eslint . --ignore-path .gitignore --ext .mjs,.js", + "eslint:quiet": "npm run eslint -- --quiet", + "eslint:fix": "npm run eslint --fix" } }