Skip to content

Task/037

Task/037 #93

Workflow file for this run

name: Tests
on: [pull_request]
jobs:
build:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: Decrypt Google credentials.json
env:
GOOGLE_API_PW: ${{ secrets.GCP_CREDENTIALS_PK }}
run: |
gpg --quiet --batch --yes --decrypt --passphrase="$GOOGLE_API_PW" \
--output $GITHUB_WORKSPACE/GoogleCloudKey.json GoogleCloudKey.json.gpg
- name: Make envfile
uses: SpicyPizza/[email protected]
with:
envkey_DB_URI: ${{ vars.CI_MONGODB_URI }}
envkey_DB_NAME: ${{ vars.CI_MONGODB_NAME }}
envkey_DB_USER: ${{ vars.CI_MONGODB_USER }}
envkey_DB_PASS: ${{ secrets.CI_MONGODB_PASSWORD }}
envkey_PORT: ${{ vars.CI_PORT }}
envkey_NODE_ENV: ${{ vars.CI_NODE_ENV }}
envkey_AUTH_DB: ${{ vars.CI_AUTH_DB }}
envkey_JWT_SECRET: ${{ secrets.CI_JWT_SECRET }}
envkey_JWT_EXPIRATION_TIME: ${{ vars.CI_JWT_EXPIRATION_TIME }}
envkey_SALT_ROUNDS: ${{ secrets.CI_SALT_ROUNDS }}
envkey_RESET_DB_ON_EACH_RELOAD: ${{ vars.CI_RESET_DB_ON_EACH_RELOAD }}
envkey_ADMIN_USERNAME: ${{ secrets.CI_ADMIN_USERNAME }}
envkey_ADMIN_PASSWORD: ${{ secrets.CI_ADMIN_PASSWORD }}
envkey_ADMIN_EMAIL: ${{ secrets.CI_ADMIN_EMAIL }}
envkey_TESTING_API_BASE_URL: ${{ vars.CI_TESTING_API_BASE_URL }}
envkey_BASE_URL: ${{ vars.CI_BASE_URL }}
envkey_DB_TEST_NAME: ${{ vars.CI_MONGODB_TEST_NAME }}
envkey_GCS_PROJECT_NAME: ${{ vars.CI_GCS_PROJECT_NAME }}
envkey_GCS_BUCKET_NAME: ${{ vars.CI_GCS_BUCKET_NAME }}
envkey_GCS_BUCKET_URL: ${{ vars.CI_GCS_BUCKET_URL }}
envkey_GCF_GENERATE_TOKEN_ENDPOINT: ${{ vars.GCF_GENERATE_TOKEN_ENDPOINT }}
envkey_GCF_VERIFY_TOKEN_ENDPOINT: ${{ vars.GCF_VERIFY_TOKEN_ENDPOINT }}
envkey_GCF_GET_PAYLOAD_FROM_TOKEN_ENDPOINT: ${{ vars.GCF_GET_PAYLOAD_FROM_TOKEN_ENDPOINT }}
envkey_SENDINBLUE_API_KEY: ${{ secrets.CI_SENDINBLUE_API_KEY }}
envkey_COURSES_SERVICE_USERNAME: ${{ secrets.CI_COURSES_SERVICE_USERNAME }}
envkey_COURSES_SERVICE_PASSWORD: ${{ secrets.CI_COURSES_SERVICE_PASSWORD }}
envkey_PAYMENT_SERVICE_USERNAME: ${{ secrets.CI_PAYMENT_SERVICE_USERNAME }}
envkey_PAYMENT_SERVICE_PASSWORD: ${{ secrets.CI_PAYMENT_SERVICE_PASSWORD }}
directory: ./server
file_name: .env
fail_on_empty: false
sort_keys: false
- name: Start MongoDBs
uses: supercharge/[email protected]
with:
mongodb-version: ${{ vars.CI_MONGODB_VERSION }}
mongodb-username: ${{ vars.CI_MONGODB_USER }}
mongodb-password: ${{ secrets.CI_MONGODB_PASSWORD }}
mongodb-db: ${{ vars.CI_MONGODB_NAME }}
mongodb-port: ${{ vars.CI_MONGODB_PORT }}
- name: Install dependencies
working-directory: ./server
run: npm ci
- name: Build project
working-directory: ./server
run: npm run build
- name: Start server
working-directory: ./server
run: npm run start --run-tests&
- name: Run tests
working-directory: ./server
run: npm test