Skip to content

Commit e018069

Browse files
committed
[Ci] E2e
1 parent 9016c68 commit e018069

File tree

5 files changed

+122
-45
lines changed

5 files changed

+122
-45
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Load environment variables'
2+
description: 'Load file into the environment variables'
3+
4+
inputs:
5+
path:
6+
description: 'Path to the env file'
7+
required: false
8+
default: '.github/env'
9+
10+
runs:
11+
using: 'composite'
12+
13+
steps:
14+
- name: ⚙️ Load file
15+
shell: bash
16+
run: cat ${{ inputs.path }} >> $GITHUB_ENV
17+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: 'Install yarn'
2+
description: 'Run yarn install with node_modules linker and cache enabled'
3+
inputs:
4+
cwd:
5+
description: "Changes node's process.cwd() if the project is not located on the root. Default to process.cwd()"
6+
required: false
7+
default: '.'
8+
cache-prefix:
9+
description: 'Add a specific cache-prefix'
10+
required: false
11+
default: 'default'
12+
cache-npm-cache:
13+
description: 'Cache npm global cache folder often used by node-gyp, prebuild binaries (invalidated on lock/os/node-version)'
14+
required: false
15+
default: 'true'
16+
enable-corepack:
17+
description: 'Enable corepack'
18+
required: false
19+
default: 'true'
20+
21+
runs:
22+
using: 'composite'
23+
24+
steps:
25+
- name: ⚙️ Enable Corepack
26+
if: inputs.enable-corepack == 'true'
27+
shell: bash
28+
working-directory: ${{ inputs.cwd }}
29+
run: corepack enable
30+
31+
- name: ⚙️ Expose yarn config as "$GITHUB_OUTPUT"
32+
id: yarn-config
33+
shell: bash
34+
working-directory: ${{ inputs.cwd }}
35+
env:
36+
YARN_ENABLE_GLOBAL_CACHE: 'false'
37+
run: |
38+
echo "CACHE_FOLDER=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
39+
echo "CURRENT_NODE_VERSION="node-$(node --version)"" >> $GITHUB_OUTPUT
40+
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's,/,-,g')" >> $GITHUB_OUTPUT
41+
echo "NPM_GLOBAL_CACHE_FOLDER=$(npm config get cache)" >> $GITHUB_OUTPUT
42+
43+
- name: ♻️ Restore yarn cache
44+
uses: actions/cache@v4
45+
id: yarn-download-cache
46+
with:
47+
path: ${{ steps.yarn-config.outputs.CACHE_FOLDER }}
48+
key: yarn-download-cache-${{ inputs.cache-prefix }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
49+
restore-keys: |
50+
yarn-download-cache-${{ inputs.cache-prefix }}-
51+
52+
- name: ♻️ Restore global npm cache folder
53+
if: inputs.cache-npm-cache == 'true'
54+
id: npm-global-cache
55+
uses: actions/cache@v4
56+
with:
57+
path: ${{ steps.yarn-config.outputs.NPM_GLOBAL_CACHE_FOLDER }}
58+
key: npm-global-cache-${{ inputs.cache-prefix }}-${{ runner.os }}-${{ steps.yarn-config.outputs.CURRENT_NODE_VERSION }}-${{ hashFiles(format('{0}/yarn.lock', inputs.cwd), format('{0}/.yarnrc.yml', inputs.cwd)) }}
59+
60+
- name: 📥 Install dependencies
61+
shell: bash
62+
working-directory: ${{ inputs.cwd }}
63+
run: yarn install --immutable --inline-builds
64+
env:
65+
# Overrides/align yarnrc.yml options (v3, v4) for a CI context
66+
YARN_ENABLE_GLOBAL_CACHE: 'false' # Use local cache folder to keep downloaded archives
67+
YARN_ENABLE_MIRROR: 'false' # Prevent populating global cache for caches misses (local cache only)
68+
YARN_NM_MODE: 'hardlinks-local' # Reduce node_modules size
69+
YARN_INSTALL_STATE_PATH: '.yarn/ci-cache/install-state.gz' # Might speed up resolution step when node_modules present
70+
# Other environment variables

.github/env

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
APP_ENV=prod
2+
APP_DEBUG=false
3+
APP_NAME=OWL
4+
APP_API_PREFIX=api
5+
APP_API_VERSION=v1
6+
API_HOST=localhost
7+
API_PORT=3000
8+
MAIL_FROM_ADDRESS=
9+
MAIL_HOST=
10+
MAIL_PORT=
11+
MAIL_USERNAME=
12+
MAIL_PASSWORD=
13+
PASSWORD_BCRYPT_SALT_ROUNDS=12
14+
JWT_SECRET=c1007baae899fcf3cda84f8f25119c8da0c28dfbbc5e680535eddccd60f5ff34
15+
JWT_EXPIRATION_TIME=10m
16+
JWT_REFRESH_TOKEN_SECRET=bef1ab54daaa8b7ee44dffad306c2eae05e071f0d42d725da28d6fffc1e69384
17+
JWT_REFRESH_TOKEN_EXPIRATION_TIME=20m
18+
JWT_COOKIE_TOKEN_DOMAIN=localhost
19+
JWT_COOKIE_TOKEN_HTTP_ONLY=false
20+
JWT_COOKIE_TOKEN_SECURE=false
21+
JWT_TOKEN_CLOCK_TOLERANCE=2

.github/workflows/test.yml

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches:
99
- main
10+
1011
jobs:
1112
build:
1213
name: build
@@ -20,11 +21,12 @@ jobs:
2021
uses: actions/setup-node@v4
2122
with:
2223
node-version: ${{ matrix.node }}
23-
- name: Install Yarn
24-
run: npm install -g yarn
25-
- name: Install dependencies
24+
- name: Install yarn
25+
uses: ./.github/actions/yarn-nm-install
26+
- name: Build
2627
run: |
27-
yarn install
28+
yarn nx build api
29+
yarn nx build app
2830
# unit-tests:
2931
# name: unit tests
3032
# runs-on: ubuntu-latest
@@ -56,8 +58,6 @@ jobs:
5658
- 3307:3306
5759
options: >-
5860
--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
59-
60-
6161
strategy:
6262
fail-fast: false
6363
matrix:
@@ -69,51 +69,17 @@ jobs:
6969
uses: actions/setup-node@v4
7070
with:
7171
node-version: ${{ matrix.node }}
72-
- name: Install Yarn
73-
run: npm install -g yarn
74-
- name: Install dependencies
75-
run: yarn install
76-
- name: e2e tests
72+
- name: Install yarn
73+
uses: ./.github/actions/yarn-nm-install
74+
- name: Load env
75+
uses: ./.github/actions/load-env
76+
- name: Run e2e tests
7777
env:
78-
# App
79-
APP_ENV: prod
80-
APP_DEBUG: false
81-
APP_NAME: OWL
82-
APP_API_PREFIX: api
83-
APP_API_VERSION: v1
84-
85-
# Api config
86-
API_HOST: localhost
87-
API_PORT: 3000
88-
89-
# DB_TYPE: sqlite | mysql
9078
DB_TYPE: mysql
91-
92-
# DB Connection Parameters
9379
DB_HOST: localhost
9480
DB_PORT: 3307
9581
DB_USER: owl
9682
DB_PASS: password
9783
DB_TIMEZONE: Z
9884
DB_SYNCHRONIZE: true
99-
100-
# SMTP Mail Config
101-
MAIL_FROM_ADDRESS:
102-
MAIL_HOST:
103-
MAIL_PORT:
104-
MAIL_USERNAME:
105-
MAIL_PASSWORD:
106-
107-
# Bcrypt
108-
PASSWORD_BCRYPT_SALT_ROUNDS: 12
109-
110-
# JWT
111-
JWT_SECRET: c1007baae899fcf3cda84f8f25119c8da0c28dfbbc5e680535eddccd60f5ff34
112-
JWT_EXPIRATION_TIME: 10m
113-
JWT_REFRESH_TOKEN_SECRET: bef1ab54daaa8b7ee44dffad306c2eae05e071f0d42d725da28d6fffc1e69384
114-
JWT_REFRESH_TOKEN_EXPIRATION_TIME: 20m
115-
JWT_COOKIE_TOKEN_DOMAIN: localhost
116-
JWT_COOKIE_TOKEN_HTTP_ONLY: false
117-
JWT_COOKIE_TOKEN_SECURE: false
118-
JWT_TOKEN_CLOCK_TOLERANCE: 2
11985
run: yarn nx run api-e2e:e2e --verbose

apps/api-e2e/project.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"implicitDependencies": ["api"],
55
"projectType": "application",
66
"targets": {
7+
"test": {
8+
"executor": "nx:noop"
9+
},
710
"e2e": {
811
"executor": "@nx/jest:jest",
912
"outputs": ["{workspaceRoot}/coverage/{e2eProjectRoot}"],

0 commit comments

Comments
 (0)