2023-05-09 12:43:16 +00:00
|
|
|
# This workflow will do a clean install of node dependencies, build the source code and run tests
|
|
|
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
|
|
|
|
|
|
name: CI Pipeline
|
|
|
|
run-name: ${{ github.actor }} is running CI pipeline
|
|
|
|
# trigger build when pushing, or when creating a pull request
|
|
|
|
on: [push, pull_request]
|
|
|
|
|
|
|
|
jobs:
|
2023-07-17 17:13:30 +00:00
|
|
|
# Label of the container job
|
2023-05-09 12:43:16 +00:00
|
|
|
japa-tests:
|
|
|
|
# run build on latest ubuntu
|
2023-05-09 12:52:42 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-07-17 17:13:30 +00:00
|
|
|
|
|
|
|
container: node:16-bullseye
|
2023-10-31 14:38:43 +00:00
|
|
|
|
2023-05-09 13:08:40 +00:00
|
|
|
services:
|
2023-07-17 17:13:30 +00:00
|
|
|
mydb:
|
|
|
|
image: postgres:latest
|
2023-07-27 12:53:34 +00:00
|
|
|
container_name: mydb
|
2023-05-09 12:57:48 +00:00
|
|
|
env:
|
2023-07-17 17:13:30 +00:00
|
|
|
POSTGRES_USER: alice
|
|
|
|
POSTGRES_PASSWORD: iEx4Vj7zBb6
|
|
|
|
POSTGRES_DB: tethys_dev
|
|
|
|
ports:
|
|
|
|
# Maps tcp port 5432 on service container to the host
|
|
|
|
- 5432:5432
|
2023-05-09 12:57:48 +00:00
|
|
|
# Set health checks to wait until postgres has started
|
2023-07-17 17:13:30 +00:00
|
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
2023-10-31 14:38:43 +00:00
|
|
|
|
2023-05-09 12:43:16 +00:00
|
|
|
steps:
|
|
|
|
# this will check out the current branch (https://github.com/actions/checkout#Push-a-commit-using-the-built-in-token)
|
2023-07-17 17:13:30 +00:00
|
|
|
- name: 1 Check out repository code
|
2023-05-09 12:43:16 +00:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
# installing Node
|
2023-07-17 17:13:30 +00:00
|
|
|
# - name: 2 Use Node.js 16.x
|
|
|
|
# uses: actions/setup-node@v1
|
|
|
|
# with:
|
|
|
|
# # this will use the latest Node 12 version
|
|
|
|
# node-version: 16.x
|
2023-05-09 12:43:16 +00:00
|
|
|
|
|
|
|
# install dependencies using clean install to avoid package lock updates
|
|
|
|
# build the project if necessary
|
|
|
|
# - run: npm run build
|
|
|
|
# - run: cd build
|
|
|
|
|
2023-07-17 17:13:30 +00:00
|
|
|
- name: 3 Install dependencies
|
2023-05-09 12:43:16 +00:00
|
|
|
run: npm ci
|
|
|
|
# - run: npm ci --omit=dev
|
|
|
|
|
2023-07-17 17:13:30 +00:00
|
|
|
- name: 4 Create .env.test file
|
|
|
|
run: cp .env.example .env.test
|
|
|
|
|
|
|
|
- name: 5 connection
|
|
|
|
run: echo "DB_CONNECTION=pg" >> .env.test
|
|
|
|
&& echo "PG_HOST=172.17.0.2" >> .env.test
|
|
|
|
&& echo "PG_PORT=5432" >> .env.test
|
|
|
|
&& echo "PG_USER=alice" >> .env.test
|
|
|
|
&& echo "PG_PASSWORD=iEx4Vj7zBb6" >> .env.test
|
|
|
|
&& echo "PG_DB_NAME=tethys_dev" >> .env.test
|
|
|
|
&& echo "NODE_ENV=test" >> .env.test
|
|
|
|
&& echo "ASSETS_DRIVER=fake" >> .env.test
|
|
|
|
&& echo "SESSION_DRIVER=memory" >> .env.test
|
|
|
|
&& echo "HASH_DRIVER=bcrypt" >> .env.test
|
|
|
|
&& echo "HOST=127.0.0.1" >> .env.test
|
|
|
|
&& echo "PORT=3333" >> .env.test
|
|
|
|
&& echo "APP_NAME=AdonisJs" >> .env.test
|
|
|
|
&& echo "APP_URL=http://${HOST}:${PORT}" >> .env.test
|
|
|
|
&& echo "CACHE_VIEWS=false" >> .env.test
|
|
|
|
&& echo "APP_KEY=pfi5N2ACN4tMJ5d8d8BPHfh3FEuvleej" >> .env.test
|
|
|
|
&& echo "DRIVE_DISK=local" >> .env.test
|
|
|
|
|
2023-05-09 12:43:16 +00:00
|
|
|
# finally run the tests
|
|
|
|
# - run: npm test
|
2023-07-17 17:13:30 +00:00
|
|
|
- name: 6 Run tests
|
|
|
|
run: npm run test
|
|
|
|
# env:
|
|
|
|
# DB_CONNECTION: pg
|
|
|
|
# PG_HOST: postgres
|
|
|
|
# PG_PORT: 5432
|
|
|
|
# PG_USER: tethys_test
|
|
|
|
# PG_PASSWORD: iEx4Vj7zBb6
|
|
|
|
# PG_DB_NAME: tethys_dev
|
|
|
|
# PORT: 3333
|
|
|
|
# HOST: 0.0.0.0
|
|
|
|
# APP_KEY: somefakekeythatis>16characters
|
|
|
|
# NODE_ENV: test
|
|
|
|
# ASSETS_DRIVER: fake
|
|
|
|
# SESSION_DRIVER: memory
|
|
|
|
# CACHE_VIEWS: false
|
|
|
|
# DRIVE_DISK: local
|
2023-05-09 12:43:16 +00:00
|
|
|
# # Save coverage report in Coveralls
|
|
|
|
# - name: Coveralls
|
|
|
|
# uses: coverallsapp/github-action@master
|
|
|
|
# with:
|
|
|
|
# github-token: ${{ secrets.GITHUB_TOKEN }}
|