Skip to content

feat: create session middleware #49

feat: create session middleware

feat: create session middleware #49

# This workflow will do a clean installation of node dependencies,
# cache/restore them, build the source code and run tests across different versions of node
# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
build:
runs-on: ${{ matrix.os }}
#runs-on: ubuntu-latest
strategy:
matrix:
os: ['ubuntu-latest']
environment: ['development', 'staging', 'production']
node-version: [18.x, 20.x]
redis-version: ['4.0', '5.0', '6.0', '6.2', '7.x', 'latest']
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# See redis enablement at: https://github.com/marketplace/actions/actions-setup-redis#usage
steps:
- name: Git checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Start Redis Server ${{ matrix.redis-version }}
uses: shogo82148/actions-setup-redis@v1
with:
redis-version: ${{ matrix.redis-version }}
- name: 'Create env file'
run: |
set -m
cp .env.example .env
cat .env
# https://stackoverflow.com/a/63350136/1743192
#
# The set -m fixes github actions CLI error: "no job control"
# See: https://stackoverflow.com/a/46829294/1743192
- name: Install dependencies
run: npm ci
- name: Check code standards
run: npm run lint
- name: Build
run: npm run build --if-present
- name: Gather coverage report
run: npm run test:coverage
env:
NODE_ENV: ${{ matrix.environment }}
REDIS_HOST: '127.0.0.1'
# GitHub actions for Node.js 18.x on ubuntu was failing due to ECONNREFUSED error
# when attempting to connect to redis.
# Override the REDIS_HOST in the .env file to use 127.0.0.1
# which is the static host bound by actions-setup-redis.
# See this reply: https://github.com/shogo82148/actions-setup-redis/issues/774#issuecomment-1521844296
# CI: true
# https://docs.github.com/en/actions/learn-github-actions/variables
# See also:
# https://github.com/marketplace/actions/set-env-variables#using-configuration-variables