Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d8fc7ae
Added build-docker.yml and docker-compose.ci.yml
knakatasf May 9, 2025
6775f3f
Edited build-docker.yml
knakatasf May 9, 2025
fb984fb
Added tests to build-docker.yml
knakatasf May 9, 2025
2c2669e
Added tests to build-docker.yml
knakatasf May 9, 2025
9c1d58b
Added tests to build-docker.yml
knakatasf May 9, 2025
5f47c60
Added tests to build-docker.yml
knakatasf May 9, 2025
1d9a0b6
Added tests to build-docker.yml
knakatasf May 9, 2025
ae5f3cb
Changed the GitHub secrets.
knakatasf May 10, 2025
943136a
Changed the GitHub secrets.
knakatasf May 10, 2025
4149d2d
Changed the GitHub secrets.
knakatasf May 10, 2025
d203d68
Changed the GitHub secrets.
knakatasf May 10, 2025
8dce2c1
Changed the GitHub secrets.
knakatasf May 10, 2025
21c212d
Changed the GitHub secrets.
knakatasf May 10, 2025
8e33791
Changed the GitHub secrets.
knakatasf May 10, 2025
9ab1afd
Changed the GitHub secrets.
knakatasf May 10, 2025
2ba0085
Changed the GitHub secrets.
knakatasf May 10, 2025
9332c95
Changed the GitHub secrets.
knakatasf May 10, 2025
9ca9b12
Changed the GitHub secrets.
knakatasf May 21, 2025
c40c8a1
Changed the GitHub secrets.
knakatasf May 21, 2025
0cc924c
Changed the GitHub secrets.
knakatasf May 21, 2025
57f825c
Changed the GitHub secrets.
knakatasf May 21, 2025
f24ddf4
Changed the GitHub secrets.
knakatasf May 21, 2025
b40443b
Added comments
knakatasf May 22, 2025
3d28542
Added comments
knakatasf May 23, 2025
f1a7106
Added comments
knakatasf May 23, 2025
5f8a7fc
Added comments
knakatasf May 23, 2025
7c9962b
CI test
knakatasf Jun 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build Docker

on:
pull_request:
branches: [ development ]
push:
branches: [ development ]

jobs:
run-docker-checks-tests:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v3

# Install Docker in GitHub Actions virtual machine
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# ${{ secrets }} is saved in Repository secrets (Repo -> Settings -> Secrets and variables -> Actions)
# This .env file will be used by docker-compose.ci.yml
- name: Create .env file for Docker Compose
run: |
cat <<EOF > .env
OED_SERVER_PORT=${{ secrets.OED_SERVER_PORT }}
OED_DB_USER=${{ secrets.OED_DB_USER }}
OED_DB_DATABASE=${{ secrets.OED_DB_DATABASE }}
OED_DB_TEST_DATABASE=${{ secrets.OED_DB_TEST_DATABASE }}
OED_DB_PASSWORD=${{ secrets.OED_DB_PASSWORD }}
OED_DB_PORT=${{ secrets.OED_DB_PORT }}
OED_TOKEN_SECRET=${{ secrets.OED_TOKEN_SECRET }}
EOF


# Build Docker images and run the containers -> integration smoke test
- name: Build & start containers
run: |
docker compose -f docker-compose.ci.yml build
docker compose -f docker-compose.ci.yml up -d

# We need the database container for the further tests
- name: Wait for database to be healthy
run: docker compose -f docker-compose.ci.yml ps

# We need git config --global -add safe.directory /usr/src/app because
# /usr/src/app is owned by the runner in GitHub Actions virtual machine whereas
# it is the root to executes git ls-files in checkHeader.sh.
# Git will deny the execution if the mounted volume (/usr/src/app) is owned by a different user.
- name: Run checks
run: |
docker compose -f docker-compose.ci.yml run --rm web \
sh -c "\
git config --global --add safe.directory /usr/src/app && \
npm ci && \
npm run check:header && \
npm run check:typescript && \
npm run check:types && \
npm run check:lint \
"

- name: Run unit and integration tests
run: |
docker compose -f docker-compose.ci.yml run --rm web \
sh -c "npm ci && npm test"

- name: Tear down
if: always()
run: docker compose -f docker-compose.ci.yml down -v
31 changes: 17 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ on:
jobs:
run-checks-tests:
env:
OED_DB_USER: test
OED_DB_PASSWORD: travisTest
OED_DB_DATABASE: travis_ci_dummy
OED_DB_TEST_DATABASE: travis_ci_test
OED_DB_HOST: postgres
OED_DB_PORT: 5432
OED_TOKEN_SECRET: travis
OED_SERVER_PORT: 3000
OED_TEST_SITE_READING_RATE: 00:15:00
POSTGRES_PASSWORD: travisTest
# ${{ secrets }} is saved in Repository secrets (Repo -> Settings -> Secrets and variables -> Actions)
OED_DB_USER: ${{ secrets.OED_DB_USER }}
OED_DB_PASSWORD: ${{ secrets.OED_DB_PASSWORD }}
OED_DB_DATABASE: ${{ secrets.OED_DB_DATABASE }}
OED_DB_TEST_DATABASE: ${{ secrets.OED_DB_TEST_DATABASE }}
OED_DB_HOST: ${{ secrets.OED_DB_HOST }}
OED_DB_PORT: ${{ secrets.OED_DB_PORT }}
OED_TOKEN_SECRET: ${{ secrets.OED_TOKEN_SECRET }}
OED_SERVER_PORT: ${{ secrets.OED_SERVER_PORT }}
OED_TEST_SITE_READING_RATE: ${{ secrets.OED_TEST_SITE_READING_RATE }}
POSTGRES_PASSWORD: ${{ secrets.OED_DB_PASSWORD }}

runs-on: ubuntu-latest
# Make sure the node version here matches containers/web/Dockerfile for the standard OED build.
Expand All @@ -28,8 +29,9 @@ jobs:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: travisTest
POSTGRES_DB: travis_ci_test
# ${{ secrets }} is saved in Repository secrets (Repo -> Settings -> Secrets and variables -> Actions)
POSTGRES_PASSWORD: ${{ secrets.OED_DB_PASSWORD }}
POSTGRES_DB: ${{ secrets.OED_DB_TEST_DATABASE }}
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down Expand Up @@ -72,8 +74,9 @@ jobs:
- name: Connect to PostgreSQL
run: node client.js
env:
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
# ${{ secrets }} is saved in Repository secrets (Repo -> Settings -> Secrets and variables -> Actions)
POSTGRES_HOST: ${{ secrets.OED_DB_HOST }}
POSTGRES_PORT: ${{ secrets.OED_DB_PORT }}

- name: node tests
run: |
Expand Down
113 changes: 113 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# *
# * This Source Code Form is subject to the terms of the Mozilla Public
# * License, v. 2.0. If a copy of the MPL was not distributed with this
# * file, You can obtain one at http://mozilla.org/MPL/2.0/.
# *

version: "3.8"
services:
# Database service. It's PostgreSQL, see the
# Dockerfile in ./database
database:
build: ./containers/database/
environment:
# Custom PGDATA per recommendations from official Docker page
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_PASSWORD: ${OED_DB_PASSWORD}
volumes:
- ./postgres-data:/var/lib/postgresql/data/pgdata
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 10s
retries: 3
# ports:
# - "5432:5432"
# Uncomment the above lines to enable access to the PostgreSQL server
# from the host machine.

web:
# Configuration variables for the app.
environment:
OED_PRODUCTION: "no"
OED_SERVER_PORT: ${OED_SERVER_PORT}
OED_DB_USER: ${OED_DB_USER}
OED_DB_DATABASE: ${OED_DB_DATABASE}
OED_DB_TEST_DATABASE: ${OED_DB_TEST_DATABASE}
OED_DB_PASSWORD: ${OED_DB_PASSWORD}
OED_DB_HOST: database # Docker will set this hostname
OED_DB_PORT: ${OED_DB_PORT}
OED_TOKEN_SECRET: ${OED_TOKEN_SECRET}
OED_LOG_FILE: log.txt
OED_MAIL_METHOD: none # Method of sending mail. Supports "secure-smtp", "none". Case insensitive.
OED_MAIL_SMTP: smtp.example.com # Edit this
OED_MAIL_SMTP_PORT: 465 # Edit this
OED_MAIL_IDENT: [email protected] # The user email that is used for sending emails (SMTP)
OED_MAIL_CREDENTIAL: credential # Set the email password for sending email here
OED_MAIL_FROM: [email protected] # The email address that the email will come from
OED_MAIL_TO: [email protected] # Set the destination address here for where to send emails
OED_MAIL_ORG: My Organization Name # Org name for mail that is included in the subject
# Changing this value does not impact what OED displays.
# What it will change is the date/time stamp on logs, notes and change dates that place the current date/time.
# It can also impact the interpretation of readings sent to OED such as Unix timestamps.
TZ: Etc/UTC # Set the timezone of the Docker container where OED runs the web services.
# If in a subdirectory, set it here
# - OED_SUBDIR=/subdir/
# Set the correct build environment.
build:
context: ./
dockerfile: ./containers/web/Dockerfile
# Link to the database so the app can persist data
links:
- database
# Load the source code into the container.
# Using a volume allows autorebuild to work.
volumes:
- ./:/usr/src/app
# Map the default port.
ports:
- "3000:3000" # Should be commented out if you uncomment 80:3000 below.
- "9229:9229" # Debug port, should be commented out for production
# For production you might want something like:
# - "80:3000"
# and comment out the debug port and 3000:3000 line above
# Don't bring this up without the DB
depends_on:
# - database
database:
# We need the database and it has to be ready for work (see healthcheck above).
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 10s
timeout: 5s
retries: 5
# Lets docker compose up work right
# If environment variable install_args is not set then it becomes blank without warning user.
command:
[
"bash",
"./src/scripts/installOED.sh",
"--nostart"
]
# Use this if you are using a docker-compose that is earlier than version 2 and comment out the one above.
# command: ["bash", "./src/scripts/installOED.sh"]

# Cypress testing service
cypress:
image: cypress/included
profiles:
- ui-testing
environment:
- CYPRESS_BASE_URL=http://web:3000
- DISPLAY=:99
working_dir: /usr/src/app
depends_on:
web:
condition: service_healthy
volumes:
- ./:/usr/src/app
entrypoint: >
/bin/sh -c "
rm -f /tmp/.X99-lock &&
Xvfb :99 -screen 0 1024x768x16"
Loading