Skip to content

Commit 6788910

Browse files
committed
Merge branch 'master' into integrate-with-frontend-web-app
2 parents 5050afe + 656c61b commit 6788910

File tree

10 files changed

+2315
-2965
lines changed

10 files changed

+2315
-2965
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.8'
2+
3+
services:
4+
mongo:
5+
image: mongo
6+
restart: always
7+
environment:
8+
MONGO_INITDB_ROOT_USERNAME: root
9+
MONGO_INITDB_ROOT_PASSWORD: password
10+
volumes:
11+
- db-data:/data/db
12+
ports:
13+
- 27017:27017
14+
15+
volumes:
16+
db-data:
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: App Container CI (With docker caching disabled)
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
# Added in response to recent changes by GitHub on 1 March 2021 involving dependabot pull requests running with read only permissions which resulted in by default GitHub secrets are unable to be read.
9+
# References:
10+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target (Announcement of changes to be made to dependabot pull requests)
11+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (Recommended security mitigations by GitHub)
12+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (Ongoing GitHub issues by users in response to the changes)
13+
pull_request_target:
14+
branches: [master]
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
timeout-minutes: 18
21+
22+
# If the Pull Request is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]". Otherwise, clone it normally.
23+
# References:
24+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
25+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (dependabot PM recommended solution)
26+
27+
if:
28+
${{ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
29+
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') }}
30+
31+
steps:
32+
- name: checkout
33+
if: ${{ github.event_name != 'pull_request_target' }}
34+
uses: actions/checkout@v2.3.4
35+
36+
- name: checkout Pull Request (dependabot[bot] only)
37+
if: ${{ github.event_name == 'pull_request_target' }}
38+
uses: actions/checkout@v2.3.4
39+
with:
40+
# Without ref with pull_request_target, it does not actually build the PR, instead it builds the latest changeset from the target repository which is not the intended behaviour. (Reference: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ [Last example])
41+
ref: ${{ github.event.pull_request.head.sha }}
42+
43+
# Pull the latest image to build, and avoid caching pull-only images.
44+
# (docker pull is faster than caching in most cases.)
45+
- name: docker-compose pull
46+
run: docker-compose pull
47+
# - name: docker layer caching
48+
# uses: satackey/action-docker-layer-caching@v0.0.11
49+
# continue-on-error: true
50+
- name: Run test in container
51+
shell: bash
52+
env:
53+
FIREBASE_CLIENT_API_KEY: ${{ secrets.FIREBASE_CLIENT_API_KEY }}
54+
# Your firebase service account information
55+
FIREBASE_ADMIN_SA_TYPE: ${{ secrets.FIREBASE_ADMIN_SA_TYPE }}
56+
FIREBASE_ADMIN_SA_PROJECT_ID: ${{ secrets.FIREBASE_ADMIN_SA_PROJECT_ID }}
57+
FIREBASE_ADMIN_SA_PRIVATE_KEY_ID: ${{ secrets.FIREBASE_ADMIN_SA_PRIVATE_KEY_ID }}
58+
FIREBASE_ADMIN_SA_PRIVATE_KEY: ${{ secrets.FIREBASE_ADMIN_SA_PRIVATE_KEY }}
59+
FIREBASE_ADMIN_SA_CLIENT_EMAIL: ${{ secrets.FIREBASE_ADMIN_SA_CLIENT_EMAIL }}
60+
FIREBASE_ADMIN_SA_CLIENT_ID: ${{ secrets.FIREBASE_ADMIN_SA_CLIENT_ID }}
61+
FIREBASE_ADMIN_SA_AUTH_URI: ${{ secrets.FIREBASE_ADMIN_SA_AUTH_URI }}
62+
FIREBASE_ADMIN_SA_TOKEN_URI: ${{ secrets.FIREBASE_ADMIN_SA_TOKEN_URI }}
63+
FIREBASE_ADMIN_SA_AUTH_PROVIDER_X509_CERT_URL: ${{ secrets.FIREBASE_ADMIN_SA_AUTH_PROVIDER_X509_CERT_URL}}
64+
FIREBASE_ADMIN_SA_CLIENT_X509_CERT_URL: ${{ secrets.FIREBASE_ADMIN_SA_CLIENT_X509_CERT_URL}}
65+
run: docker-compose --file ./.github/ci/docker-compose-test-ci.yml up --build --exit-code-from app

.github/workflows/app-test-container.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,50 @@ on:
55
branches: [master]
66
pull_request:
77
branches: [master]
8+
# Added in response to recent changes by GitHub on 1 March 2021 involving dependabot pull requests running with read only permissions which resulted in by default GitHub secrets are unable to be read.
9+
# References:
10+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target (Announcement of changes to be made to dependabot pull requests)
11+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (Recommended security mitigations by GitHub)
12+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (Ongoing GitHub issues by users in response to the changes)
13+
pull_request_target:
14+
branches: [master]
815

916
jobs:
1017
build:
1118
runs-on: ubuntu-latest
1219

13-
timeout-minutes: 8
20+
timeout-minutes: 18
21+
22+
# If the Pull Request is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]". Otherwise, clone it normally.
23+
# References:
24+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
25+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (dependabot PM recommended solution)
26+
27+
if:
28+
${{ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
29+
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') }}
1430

1531
steps:
1632
- name: checkout
17-
uses: actions/checkout@v2
33+
if: ${{ github.event_name != 'pull_request_target' }}
34+
uses: actions/checkout@v2.3.4
35+
36+
- name: checkout Pull Request (dependabot[bot] only)
37+
if: ${{ github.event_name == 'pull_request_target' }}
38+
uses: actions/checkout@v2.3.4
39+
with:
40+
# Without ref with pull_request_target, it does not actually build the PR, instead it builds the latest changeset from the target repository which is not the intended behaviour. (Reference: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ [Last example])
41+
ref: ${{ github.event.pull_request.head.sha }}
42+
1843
# Pull the latest image to build, and avoid caching pull-only images.
1944
# (docker pull is faster than caching in most cases.)
2045
- name: docker-compose pull
2146
run: docker-compose pull
47+
2248
- name: docker layer caching
23-
uses: satackey/action-docker-layer-caching@v0.0.10
49+
uses: satackey/action-docker-layer-caching@v0.0.11
2450
continue-on-error: true
51+
2552
- name: Run test in container
2653
shell: bash
2754
env:
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node while connecting to a mongodb docker instance
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js with docker db CI
5+
6+
on:
7+
push:
8+
branches: [master]
9+
pull_request:
10+
branches: [master]
11+
# Added in response to recent changes by GitHub on 1 March 2021 involving dependabot pull requests running with read only permissions which resulted in by default GitHub secrets are unable to be read.
12+
# References:
13+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target (Announcement of changes to be made to dependabot pull requests)
14+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (Recommended security mitigations by GitHub)
15+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (Ongoing GitHub issues by users in response to the changes)
16+
pull_request_target:
17+
branches: [master]
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
23+
timeout-minutes: 18
24+
25+
strategy:
26+
matrix:
27+
node-version: [14, 16]
28+
29+
# If the Pull Request is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]". Otherwise, clone it normally.
30+
# References:
31+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
32+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (dependabot PM recommended solution)
33+
34+
if:
35+
${{ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
36+
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') }}
37+
38+
steps:
39+
- name: checkout
40+
if: ${{ github.event_name != 'pull_request_target' }}
41+
uses: actions/checkout@v2.3.4
42+
43+
- name: checkout Pull Request (dependabot[bot] only)
44+
if: ${{ github.event_name == 'pull_request_target' }}
45+
uses: actions/checkout@v2.3.4
46+
with:
47+
# Without ref with pull_request_target, it does not actually build the PR, instead it builds the latest changeset from the target repository which is not the intended behaviour. (Reference: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ [Last example])
48+
ref: ${{ github.event.pull_request.head.sha }}
49+
50+
# Pull the latest image to build, and avoid caching pull-only images.
51+
# (docker pull is faster than caching in most cases.)
52+
- name: docker-compose pull
53+
run: docker-compose pull
54+
55+
- name: Use Node.js ${{ matrix.node-version }}
56+
uses: actions/setup-node@v2.2.0
57+
with:
58+
node-version: ${{ matrix.node-version }}
59+
check-latest: true
60+
cache: npm
61+
- name: npm ci
62+
run: npm ci
63+
- name: npm run build
64+
run: npm run build --if-present
65+
- name: Build and Start mongodb in docker instance
66+
shell: bash
67+
run: docker-compose --file ./.github/ci/docker-compose-test-ci-db-only.yml up --build --detach
68+
- name: Running test cases
69+
run: npm run test-ci
70+
env:
71+
PORT: ${{ secrets.PORT }}
72+
TEST_MONGODB_URI: mongodb://root:password@localhost:27017/softwareRepositoryTest?authSource=admin
73+
FIREBASE_CLIENT_API_KEY: ${{ secrets.FIREBASE_CLIENT_API_KEY }}
74+
# Your firebase service account information
75+
FIREBASE_ADMIN_SA_TYPE: ${{ secrets.FIREBASE_ADMIN_SA_TYPE }}
76+
FIREBASE_ADMIN_SA_PROJECT_ID: ${{ secrets.FIREBASE_ADMIN_SA_PROJECT_ID }}
77+
FIREBASE_ADMIN_SA_PRIVATE_KEY_ID: ${{ secrets.FIREBASE_ADMIN_SA_PRIVATE_KEY_ID }}
78+
FIREBASE_ADMIN_SA_PRIVATE_KEY: ${{ secrets.FIREBASE_ADMIN_SA_PRIVATE_KEY }}
79+
FIREBASE_ADMIN_SA_CLIENT_EMAIL: ${{ secrets.FIREBASE_ADMIN_SA_CLIENT_EMAIL }}
80+
FIREBASE_ADMIN_SA_CLIENT_ID: ${{ secrets.FIREBASE_ADMIN_SA_CLIENT_ID }}
81+
FIREBASE_ADMIN_SA_AUTH_URI: ${{ secrets.FIREBASE_ADMIN_SA_AUTH_URI }}
82+
FIREBASE_ADMIN_SA_TOKEN_URI: ${{ secrets.FIREBASE_ADMIN_SA_TOKEN_URI }}
83+
FIREBASE_ADMIN_SA_AUTH_PROVIDER_X509_CERT_URL: ${{ secrets.FIREBASE_ADMIN_SA_AUTH_PROVIDER_X509_CERT_URL}}
84+
FIREBASE_ADMIN_SA_CLIENT_X509_CERT_URL: ${{ secrets.FIREBASE_ADMIN_SA_CLIENT_X509_CERT_URL}}

.github/workflows/node.js.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
33
# Addition of Cache Action
44

5+
## TODO: Add mitigations for GitHub Actions dependabot read only changes which resulted in GitHub Secrets cannot be read.
6+
## References:
7+
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target (Announcement of changes to be made to dependabot pull requests)
8+
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (Recommended security mitigations by GitHub)
9+
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-797125425 (Ongoing GitHub issues by users in response to the changes)
10+
511
name: Node.js CI
612

713
on:
@@ -16,21 +22,16 @@ jobs:
1622

1723
strategy:
1824
matrix:
19-
node-version: [12.x]
25+
node-version: [14.x]
2026

2127
steps:
22-
- uses: actions/checkout@v2
23-
- name: Cache artifacts such as dependencies and build outputs
24-
uses: actions/cache@v2
25-
with:
26-
path: ~/.npm
27-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
28-
restore-keys: |
29-
${{ runner.os }}-node-
28+
- uses: actions/checkout@v2.3.4
3029
- name: Use Node.js ${{ matrix.node-version }}
31-
uses: actions/setup-node@v2.1.2
30+
uses: actions/setup-node@v2.2.0
3231
with:
3332
node-version: ${{ matrix.node-version }}
33+
check-latest: true
34+
cache: npm
3435
- run: npm ci
3536
- run: npm run build --if-present
3637
- run: npm test

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# With comments to aid in my learning of docker.
33

44
# To use official nodejs base docker image.
5-
FROM node:12
5+
FROM node:lts
66

77
# The working directory where any subsequent instructions in the Dockerfile will be executed on.
88
WORKDIR /app

Dockerfile-ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# With comments to aid in my learning of docker.
33

44
# To use official nodejs base docker image.
5-
FROM node:12
5+
FROM node:lts
66

77
# The working directory where any subsequent instructions in the Dockerfile will be executed on.
88
WORKDIR /app

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Software Repository (API Backend)
22

33
[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/learnsoftwaredevelopment/SoftwareRepository/blob/master/LICENSE)
4-
![GitHub Node.js CI](https://github.com/learnsoftwaredevelopment/SoftwareRepository/workflows/Node.js%20CI/badge.svg?branch=master)
5-
![App Container CI](https://github.com/learnsoftwaredevelopment/SoftwareRepository/workflows/App%20Container%20CI/badge.svg?branch=master)
4+
[![Node.js with docker db CI](https://github.com/learnsoftwaredevelopment/SoftwareRepository/actions/workflows/node.js-with-docker-db.yml/badge.svg)](https://github.com/learnsoftwaredevelopment/SoftwareRepository/actions/workflows/node.js-with-docker-db.yml)
5+
![App Container CI](https://github.com/learnsoftwaredevelopment/SoftwareRepository/actions/workflows/app-test-container-no-docker-cache.yml/badge.svg?branch=master)
66

77
## Introduction
88

@@ -169,7 +169,7 @@ A list of the technologies and frameworks used in this project
169169

170170
### Backend Technologies
171171

172-
- Node.js (Node 12)
172+
- Node.js (Node.js LTS)
173173
- MongoDB
174174
- Firebase Authentication
175175

0 commit comments

Comments
 (0)