From 2a66fc71acfd7e7b22de1a2496e99a64f236b254 Mon Sep 17 00:00:00 2001 From: Aleksei Gurianov Date: Fri, 30 Sep 2022 19:00:13 +0300 Subject: [PATCH] setup github actions --- .github/workflows/main.yml | 46 ++++++++++++++++++++++++++++++++++++++ vite.config.ts | 3 +++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..dc8fdf1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,46 @@ +name: Node.js CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build_deploy: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Get npm cache directory + id: npm-cache-dir + run: | + echo "::set-output name=dir::$(npm config get cache)" + - uses: actions/cache@v3 + id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' + with: + path: ${{ steps.npm-cache-dir.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - run: npm ci --legacy-peer-deps + - run: npm run lint + - run: npm test -- --coverage + - name: "Report Coverage" + if: always() # Also generate the report if tests are failing + uses: davelosert/vitest-coverage-report-action@v1 + with: + vite-config-path: vite.config.ts + - run: npm run build + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + role-to-assume: ${{ secrets.AWS_ROLE_FOR_GITHUB }} + aws-region: us-east-1 + - run: npm run deploy diff --git a/vite.config.ts b/vite.config.ts index dff5e66..07f215a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -29,5 +29,8 @@ export default defineConfig({ globals: true, environment: "jsdom", setupFiles: "./src/setupTests.ts", + coverage: { + reporter: ["text", "json-summary", "json"], + }, }, });