Merge pull request #225 from ElzabeEls/17-sorting-recipes-by-date #188
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Node.js CI | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x, 20.x, 22.x] | ||
env: # Set environment variables at the job level | ||
MONGODB_URI: ${{ secrets.MONGODB_URI }} # Ensure this is correctly set | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- name: Debug MongoDB URI | ||
run: echo "MONGODB_URI is set to: $MONGODB_URI" # Use the env variable instead of the secret directly | ||
env: | ||
MONGODB_URI: ${{ secrets.MONGODB_URI }} | ||
- name: Cache node modules | ||
uses: actions/[email protected] | ||
with: | ||
path: node_modules | ||
key: node-modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }} | ||
restore-keys: | | ||
node-modules-${{ runner.os }}-node-${{ matrix.node-version }} | ||
- run: npm ci --legacy-peer-deps | ||
- run: npm run lint | ||
- run: npm run build --if-present | ||
- name: Run tests | ||
run: | | ||
cd backend | ||
npx mocha --config .mocharc.json |