From 513c24fe69fbca2a1e9f3eeb7a96689909ec1ce7 Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 13:40:26 +0300 Subject: [PATCH 1/3] added a github actions that runs the tests and reports coverage --- .github/workflows/test.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8c98a0b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +name: CI - Test & Coverage + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + + steps: + - name: ๐Ÿ“ฅ Checkout code + uses: actions/checkout@v4 + + - name: ๐ŸŸข Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + + - name: ๐Ÿ“ฆ Install dependencies + run: npm ci + + - name: ๐Ÿ”จ Build the app (NestJS) + run: npm run build + + - name: ๐Ÿงช Run tests with coverage + run: npm run test:cov + + - name: ๐Ÿ“ค Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/ From dbf0f601566a3ed8eb8a95e9e80c5bcfacd44e10 Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 13:45:23 +0300 Subject: [PATCH 2/3] updated the workflow to use pnpm --- .github/workflows/test.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c98a0b..3b1d9af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,26 +12,31 @@ jobs: strategy: matrix: - node-version: [18.x, 20.x, 22.x] + node-version: [22.x] steps: - name: ๐Ÿ“ฅ Checkout code uses: actions/checkout@v4 + - name: ๐Ÿ“ฆ Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + - name: ๐ŸŸข Setup Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - cache: "npm" + cache: "pnpm" - name: ๐Ÿ“ฆ Install dependencies - run: npm ci + run: pnpm install - name: ๐Ÿ”จ Build the app (NestJS) - run: npm run build + run: pnpm run build - name: ๐Ÿงช Run tests with coverage - run: npm run test:cov + run: pnpm run test:cov - name: ๐Ÿ“ค Upload coverage report uses: actions/upload-artifact@v4 From f4a9b67c02c0cde2b5abd9e1d4df9e5305ac2f7d Mon Sep 17 00:00:00 2001 From: Alexander Shestakov Date: Sat, 31 May 2025 13:49:15 +0300 Subject: [PATCH 3/3] temporarily test only controller to check if action works --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3b1d9af..fc6156c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: run: pnpm run build - name: ๐Ÿงช Run tests with coverage - run: pnpm run test:cov + run: pnpm run test:cov -t controller - name: ๐Ÿ“ค Upload coverage report uses: actions/upload-artifact@v4