Skip to content

Change userId creation to auth service #4

Change userId creation to auth service

Change userId creation to auth service #4

Workflow file for this run

# WARNING
# This workflow does not check for 'pull_request' event_name
# Do not use it for on:push
name: Lint • Test • E2E
on:
pull_request:
branches:
- staging
- main
env:
NODE_VERSION: 21.6.1
jobs:
setup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Cache NPM
uses: actions/cache/save@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm install
shared-code:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore npm cache
uses: actions/cache/restore@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
fail-on-cache-miss: true
- name: Install dependencies
run: npm ci
- name: Lint
run: npx nx lint shared
- name: Unit and Integration tests
run: npx nx test shared -- --coverage --coverageReporters=cobertura
- name: Coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/shared/cobertura-coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 90'
- name: Rename report file
run: mv code-coverage-results.md shared-code-coverage-results.md
- name: Cache coverage report
uses: actions/cache/save@v3
with:
path: shared-code-coverage-results.md
key: ${{ runner.os }}-shared-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
auth-service:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore npm cache
uses: actions/cache/restore@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
fail-on-cache-miss: true
- name: Install dependencies
run: npm ci
- name: Lint
run: npx nx lint auth-service
- name: Lint E2E
run: npx nx lint auth-service-e2e
- name: Unit and Integration tests
run: npx nx test auth-service -- --coverage --coverageReporters=cobertura
- name: Coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/apps/auth-service/cobertura-coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 90'
- name: Rename report file
run: mv code-coverage-results.md auth-service-coverage-results.md
- name: Cache coverage report
uses: actions/cache/save@v3
with:
path: auth-service-coverage-results.md
key: ${{ runner.os }}-auth-service-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
financial-service:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore npm cache
uses: actions/cache/restore@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
fail-on-cache-miss: true
- name: Install dependencies
run: npm ci
- name: Lint
run: npx nx lint financial-service
- name: Lint E2E
run: npx nx lint financial-service-e2e
- name: Unit and Integration tests
run: npx nx test financial-service -- --coverage --coverageReporters=cobertura
- name: Coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/apps/financial-service/cobertura-coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 90'
- name: Rename report file
run: mv code-coverage-results.md financial-service-coverage-results.md
- name: Cache coverage report
uses: actions/cache/save@v3
with:
path: financial-service-coverage-results.md
key: ${{ runner.os }}-financial-service-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
user-service:
needs: setup
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore npm cache
uses: actions/cache/restore@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
fail-on-cache-miss: true
- name: Install dependencies
run: npm ci
- name: Lint
run: npx nx lint user-service
- name: Lint E2E
run: npx nx lint user-service-e2e
- name: Unit and Integration tests
run: npx nx test user-service -- --coverage --coverageReporters=cobertura
- name: Coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/apps/user-service/cobertura-coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '80 90'
- name: Rename report file
run: mv code-coverage-results.md user-service-coverage-results.md
- name: Cache coverage report
uses: actions/cache/save@v3
with:
path: user-service-coverage-results.md
key: ${{ runner.os }}-user-service-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
coverage-report:
needs:
- shared-code
- auth-service
- financial-service
- user-service
runs-on: ubuntu-latest
steps:
- name: Restore shared code report
uses: actions/cache/restore@v3
with:
path: shared-code-coverage-results.md
key: ${{ runner.os }}-shared-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
fail-on-cache-miss: true
- name: Restore auth-service report
uses: actions/cache/restore@v3
with:
path: auth-service-coverage-results.md
key: ${{ runner.os }}-auth-service-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
fail-on-cache-miss: true
- name: Restore financial-service report
uses: actions/cache/restore@v3
with:
path: financial-service-coverage-results.md
key: ${{ runner.os }}-financial-service-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
fail-on-cache-miss: true
- name: Restore user-service report
uses: actions/cache/restore@v3
with:
path: user-service-coverage-results.md
key: ${{ runner.os }}-user-service-coverage-report-${{ github.run_id }}-${{ github.run_attempt }}
fail-on-cache-miss: true
- name: Set title for shared code
run: |
cat <<EOF >> code-coverage-output.md
## 📦 Shared
EOF
- name: Merge shared report file
run: cat shared-code-coverage-results.md >> code-coverage-output.md
- name: Set title for auth-service
run: |
cat <<EOF >> code-coverage-output.md
## 📦 Auth Service
EOF
- name: Merge auth-service report file
run: cat auth-service-coverage-results.md >> code-coverage-output.md
- name: Set title for financial-service
run: |
cat <<EOF >> code-coverage-output.md
## 📦 Financial Service
EOF
- name: Merge financial-service report file
run: cat financial-service-coverage-results.md >> code-coverage-output.md
- name: Set title for user-service
run: |
cat <<EOF >> code-coverage-output.md
## 📦 User Service
EOF
- name: Merge user-service report file
run: cat user-service-coverage-results.md >> code-coverage-output.md
- name: Set final PR message
run: |
cat <<EOF >> code-coverage-output.md
⛔️ This comment can be replaced by Github Actions. Do not quote or react to it.
EOF
- name: Add coverage PR comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: code-coverage
recreate: true
path: code-coverage-output.md
auth-service-e2e:
needs: coverage-report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore npm cache
uses: actions/cache/restore@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
fail-on-cache-miss: true
- name: Install dependencies
run: npm ci
- name: Build
run: npx nx build auth-service
- name: Load .env variables
id: dotenv
uses: falti/dotenv-action@v1.0.4
- name: Testing
run: npx nx e2e auth-service-e2e
env:
AUTH_SERVICE_PORT: ${{ steps.dotenv.outputs.AUTH_SERVICE_PORT }}
DATABASE_AUTH_HOST: ${{ steps.dotenv.outputs.DATABASE_AUTH_HOST }}
DATABASE_AUTH_PORT: ${{ steps.dotenv.outputs.DATABASE_AUTH_PORT }}
DATABASE_AUTH_USERNAME: ${{ steps.dotenv.outputs.DATABASE_AUTH_USERNAME }}
DATABASE_AUTH_PASSWORD: ${{ steps.dotenv.outputs.DATABASE_AUTH_PASSWORD }}
DATABASE_AUTH_DBNAME: ${{ steps.dotenv.outputs.DATABASE_AUTH_DBNAME }}
JWT_SECRET_KEY: ${{ steps.dotenv.outputs.JWT_SECRET_KEY }}
JWT_EXPIRES_IN: ${{ steps.dotenv.outputs.JWT_EXPIRES_IN }}
financial-service-e2e:
needs: coverage-report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore npm cache
uses: actions/cache/restore@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
fail-on-cache-miss: true
- name: Install dependencies
run: npm ci
- name: Build
run: npx nx build financial-service
- name: Load .env variables
id: dotenv
uses: falti/dotenv-action@v1.0.4
- name: Testing
run: npx nx e2e financial-service-e2e
env:
FINANCIAL_SERVICE_PORT: ${{ steps.dotenv.outputs.FINANCIAL_SERVICE_PORT }}
DATABASE_FINANCIAL_HOST: ${{ steps.dotenv.outputs.DATABASE_FINANCIAL_HOST }}
DATABASE_FINANCIAL_PORT: ${{ steps.dotenv.outputs.DATABASE_FINANCIAL_PORT }}
DATABASE_FINANCIAL_USERNAME: ${{ steps.dotenv.outputs.DATABASE_FINANCIAL_USERNAME }}
DATABASE_FINANCIAL_PASSWORD: ${{ steps.dotenv.outputs.DATABASE_FINANCIAL_PASSWORD }}
DATABASE_FINANCIAL_DBNAME: ${{ steps.dotenv.outputs.DATABASE_FINANCIAL_DBNAME }}
JWT_SECRET_KEY: ${{ steps.dotenv.outputs.JWT_SECRET_KEY }}
JWT_MAX_AGE: ${{ steps.dotenv.outputs.JWT_MAX_AGE }}
user-service-e2e:
needs: coverage-report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore npm cache
uses: actions/cache/restore@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
fail-on-cache-miss: true
- name: Install dependencies
run: npm ci
- name: Build
run: npx nx build user-service
- name: Load .env variables
id: dotenv
uses: falti/dotenv-action@v1.0.4
- name: Testing
run: npx nx e2e user-service-e2e
env:
USER_SERVICE_PORT: ${{ steps.dotenv.outputs.USER_SERVICE_PORT }}
DATABASE_USER_HOST: ${{ steps.dotenv.outputs.DATABASE_USER_HOST }}
DATABASE_USER_PORT: ${{ steps.dotenv.outputs.DATABASE_USER_PORT }}
DATABASE_USER_USERNAME: ${{ steps.dotenv.outputs.DATABASE_USER_USERNAME }}
DATABASE_USER_PASSWORD: ${{ steps.dotenv.outputs.DATABASE_USER_PASSWORD }}
DATABASE_USER_DBNAME: ${{ steps.dotenv.outputs.DATABASE_USER_DBNAME }}
JWT_SECRET_KEY: ${{ steps.dotenv.outputs.JWT_SECRET_KEY }}
JWT_MAX_AGE: ${{ steps.dotenv.outputs.JWT_MAX_AGE }}