Test lib refactor #34
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pull Request Checks | |
| on: | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.base_ref || github.actor }}-${{ github.head_ref || github.ref_name }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| id-token: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| setup: | |
| name: Setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read .nvmrc | |
| run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "${{ env.NVMRC }}" | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: npm ci | |
| build: | |
| name: Build | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read .nvmrc | |
| run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "${{ env.NVMRC }}" | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Prepare Database | |
| env: | |
| DATABASE_URL: "file:./test.db" | |
| run: | | |
| npx prisma generate | |
| npx prisma db push --accept-data-loss | |
| npx prisma db seed | |
| - name: Build | |
| id: build | |
| env: | |
| DATABASE_URL: "file:./test.db" | |
| run: | | |
| start_time=$(date +%s) | |
| npm run build | |
| end_time=$(date +%s) | |
| duration=$((end_time - start_time)) | |
| echo "duration=$duration" >> $GITHUB_OUTPUT | |
| - name: Build Teardown | |
| id: build-teardown | |
| env: | |
| DATABASE_URL: "file:./test.db" | |
| run: | | |
| npm run cleanup:dev | |
| - name: Post Build Comment | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| let output = `### ποΈ Build Results`; | |
| if ( "${{ job.status }}" == "success" ) { | |
| output = `### ποΈ Build Results | |
| β Build completed successfully in ${{ steps.build.outputs.duration }} seconds`; | |
| } else { | |
| output = `### ποΈ Build Results | |
| β Build failed | |
| Please check the build logs for more details.`; | |
| } | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: output | |
| }); | |
| lint: | |
| name: Lint | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read .nvmrc | |
| run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "${{ env.NVMRC }}" | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Lint | |
| id: lint | |
| run: | | |
| start_time=$(date +%s) | |
| npm run lint > lint_output.txt 2>&1 || true | |
| end_time=$(date +%s) | |
| duration=$((end_time - start_time)) | |
| echo "duration=$duration" >> $GITHUB_OUTPUT | |
| cat lint_output.txt | |
| - name: Post Lint Comment | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| let output = `### π Lint Results`; | |
| if ( "${{ job.status }}" == "success" ) { | |
| output = `### π Lint Results | |
| β Lint passed successfully in ${{ steps.lint.outputs.duration }} seconds`; | |
| } else { | |
| output = `### π Lint Results | |
| β Lint failed`; | |
| output += `\n\`\`\`\n`; | |
| output += `cat lint_output.txt\n`; | |
| output += `\`\`\`\n`; | |
| } | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: output | |
| }); | |
| test: | |
| name: Test | |
| needs: setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read .nvmrc | |
| run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "${{ env.NVMRC }}" | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Run Tests | |
| id: test | |
| run: | | |
| start_time=$(date +%s) | |
| npm run test | |
| end_time=$(date +%s) | |
| duration=$((end_time - start_time)) | |
| echo "duration=$duration" >> $GITHUB_OUTPUT | |
| # - name: Upload Coverage Report | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: coverage-report | |
| # path: coverage/ | |
| # retention-days: 30 | |
| - name: Post Test Summary Comment | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| let output = `### π§ͺ Test Results`; | |
| if ( "${{ job.status }}" == "success" ) { | |
| output = `### π§ͺ Test Results | |
| β Tests completed successfully in ${{ steps.test.outputs.duration }} seconds`; | |
| } else { | |
| output = `### π§ͺ Test Results | |
| β Tests failed | |
| Please check the test logs for more details.`; | |
| } | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: output | |
| }); | |
| # - name: Post Coverage Comment | |
| # uses: romeovs/lcov-reporter-action@v0.3.1 | |
| # with: | |
| # github-token: ${{ secrets.GITHUB_TOKEN }} | |
| # lcov-file: ./coverage/lcov.info | |
| # delete-old-comments: true | |
| # title: Test Coverage Report |