From d8fc7aeb6ec2c86e5cb87b1baaa3850ddd280ff9 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 15:27:06 -0700 Subject: [PATCH 01/27] Added build-docker.yml and docker-compose.ci.yml --- .github/workflows/build-docker.yml | 33 +++++++++ docker-compose.ci.yml | 113 +++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 .github/workflows/build-docker.yml create mode 100644 docker-compose.ci.yml diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 000000000..63ff31b4f --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,33 @@ +name: Docker-build + +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 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Install PostgreSQL Client + run: sudo apt-get update && sudo apt-get install -y postgresql-client + + - name: Build and start containers + run: | + sudo docker compose -f docker-compose.ci.yml up + + - name: Install dependencies inside the web container + run: | + sudo docker compose run web sh -c "npm install" + + - name: Run tests inside the web container + run: | + sudo docker compose exec web sh -c "npm run test" diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml new file mode 100644 index 000000000..5c7852821 --- /dev/null +++ b/docker-compose.ci.yml @@ -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=opened # default postgres password that should be changed for security. + 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=yes + - OED_SERVER_PORT=3000 + - OED_DB_USER=oed + - OED_DB_DATABASE=oed + - OED_DB_TEST_DATABASE=oed_testing + - OED_DB_PASSWORD=opened + - OED_DB_HOST=database # Docker will set this hostname + - OED_DB_PORT=5432 + - 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=someone@example.com # 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=mydomain@example.com # The email address that the email will come from + - OED_MAIL_TO=someone@example.com # 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" From 6775f3ffcabb8240383a3fd1293faadb8633ef79 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 15:37:37 -0700 Subject: [PATCH 02/27] Edited build-docker.yml --- .github/workflows/build-docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 63ff31b4f..b54c88133 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -22,12 +22,12 @@ jobs: - name: Build and start containers run: | - sudo docker compose -f docker-compose.ci.yml up + docker compose -f docker-compose.ci.yml up -d - name: Install dependencies inside the web container run: | - sudo docker compose run web sh -c "npm install" + docker compose run web sh -c "npm install" - name: Run tests inside the web container run: | - sudo docker compose exec web sh -c "npm run test" + docker compose exec web sh -c "npm run test" From fb984fbc9bcd24add425cf127b47066ed57cdf14 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 15:43:38 -0700 Subject: [PATCH 03/27] Added tests to build-docker.yml --- .github/workflows/build-docker.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index b54c88133..e567cf559 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -30,4 +30,8 @@ jobs: - name: Run tests inside the web container run: | + docker compose exec web sh -c "npm run check:header" + docker compose exec web sh -c "npm run check:typescript" + docker compose exec web sh -c "npm run check:types" + docker compose exec web sh -c "npm run check:lint" docker compose exec web sh -c "npm run test" From 2c2669e53f0f9309b32a28051bc2a25333daa4a8 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 15:50:00 -0700 Subject: [PATCH 04/27] Added tests to build-docker.yml --- .github/workflows/build-docker.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index e567cf559..b54c88133 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -30,8 +30,4 @@ jobs: - name: Run tests inside the web container run: | - docker compose exec web sh -c "npm run check:header" - docker compose exec web sh -c "npm run check:typescript" - docker compose exec web sh -c "npm run check:types" - docker compose exec web sh -c "npm run check:lint" docker compose exec web sh -c "npm run test" From 9c1d58bd38c25ef3ffd4d01fc1efb68e686f410c Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 15:57:37 -0700 Subject: [PATCH 05/27] Added tests to build-docker.yml --- .github/workflows/build-docker.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index b54c88133..ac07213ae 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -1,10 +1,10 @@ -name: Docker-build +name: Docker CI on: pull_request: - branches: [ development ] + branches: [development] push: - branches: [ development ] + branches: [development] jobs: run-docker-checks-tests: @@ -17,17 +17,33 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + # (Optional) if you need psql client on the runner - name: Install PostgreSQL Client run: sudo apt-get update && sudo apt-get install -y postgresql-client - - name: Build and start containers + - name: Build & start containers run: | + docker compose -f docker-compose.ci.yml build docker compose -f docker-compose.ci.yml up -d + - name: Wait for DB & Web to be healthy + run: docker compose -f docker-compose.ci.yml ps + - name: Install dependencies inside the web container run: | - docker compose run web sh -c "npm install" + docker compose -f docker-compose.ci.yml run --rm web \ + sh -c "npm ci" + + - name: Run lint & type checks + run: | + docker compose -f docker-compose.ci.yml run --rm web \ + sh -c "npm run check:header && npm run check:typescript && npm run check:types && npm run check:lint" - - name: Run tests inside the web container + - name: Run unit & integration tests run: | - docker compose exec web sh -c "npm run test" + docker compose -f docker-compose.ci.yml run --rm web \ + sh -c "npm test" + + - name: Tear down + if: always() + run: docker compose -f docker-compose.ci.yml down -v From 5f47c60da7c943e67c30ee7c9c01130fac211cff Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 16:00:00 -0700 Subject: [PATCH 06/27] Added tests to build-docker.yml --- .github/workflows/build-docker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index ac07213ae..09bea7a99 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -34,10 +34,10 @@ jobs: docker compose -f docker-compose.ci.yml run --rm web \ sh -c "npm ci" - - name: Run lint & type checks - run: | - docker compose -f docker-compose.ci.yml run --rm web \ - sh -c "npm run check:header && npm run check:typescript && npm run check:types && npm run check:lint" +# - name: Run lint & type checks +# run: | +# docker compose -f docker-compose.ci.yml run --rm web \ +# sh -c "npm run check:header && npm run check:typescript && npm run check:types && npm run check:lint" - name: Run unit & integration tests run: | From 1d9a0b6bc34836cf15fc1f380921ea1a34ce0b78 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 16:21:40 -0700 Subject: [PATCH 07/27] Added tests to build-docker.yml --- .github/workflows/build-docker.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 09bea7a99..880b19503 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -17,10 +17,6 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - # (Optional) if you need psql client on the runner - - name: Install PostgreSQL Client - run: sudo apt-get update && sudo apt-get install -y postgresql-client - - name: Build & start containers run: | docker compose -f docker-compose.ci.yml build From ae5f3cb97e167bd15910144bed1596ca91d0609a Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 18:11:27 -0700 Subject: [PATCH 08/27] Changed the GitHub secrets. --- .github/workflows/build.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2453f085..499eeef3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,16 +9,16 @@ 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 + 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.POSTGRES_PASSWORD }} runs-on: ubuntu-latest # Make sure the node version here matches containers/web/Dockerfile for the standard OED build. @@ -28,8 +28,8 @@ jobs: postgres: image: postgres env: - POSTGRES_PASSWORD: travisTest - POSTGRES_DB: travis_ci_test + POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} + POSTGRES_DB: ${{ secrets.POSTGRES_DB }} options: >- --health-cmd pg_isready --health-interval 10s @@ -72,8 +72,8 @@ jobs: - name: Connect to PostgreSQL run: node client.js env: - POSTGRES_HOST: postgres - POSTGRES_PORT: 5432 + POSTGRES_HOST: ${{ secrets.OED_DB_HOST }} + POSTGRES_PORT: ${{ secrets.OED_DB_PORT }} - name: node tests run: | From 943136a8e00f395a78e17b9bcc13f7c1c8f5ed3b Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 20:23:09 -0700 Subject: [PATCH 09/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 880b19503..e1d542914 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -1,4 +1,4 @@ -name: Docker CI +name: Build Docker on: pull_request: From 4149d2da6f53bf2c76a10d10d1e557ba44da85ee Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 20:44:28 -0700 Subject: [PATCH 10/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 12 +++++++++ docker-compose.ci.yml | 42 +++++++++++++++--------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index e1d542914..fa56e3eb1 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -17,6 +17,18 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Create .env file for Docker Compose + run: | + cat < .env + OED_DB_DATABASE=${{ secrets.OED_DB_DATABASE }} + OED_DB_PASSWORD=${{ secrets.OED_DB_PASSWORD }} + OED_DB_PORT=${{ secrets.OED_DB_PORT }} + OED_DB_TEST_DATABASE=${{ secrets.OED_DB_TEST_DATABASE }} + OED_DB_USER=${{ secrets.OED_DB_USER }} + OED_SERVER_PORT=${{ secrets.OED_SERVER_PORT }} + OED_TOKEN_SECRET=${{ secrets.OED_TOKEN_SECRET }} + EOF + - name: Build & start containers run: | docker compose -f docker-compose.ci.yml build diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 5c7852821..5ef1711a8 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -12,8 +12,8 @@ services: build: ./containers/database/ environment: # Custom PGDATA per recommendations from official Docker page - - PGDATA=/var/lib/postgresql/data/pgdata - - POSTGRES_PASSWORD=opened # default postgres password that should be changed for security. + PGDATA: /var/lib/postgresql/data/pgdata + POSTGRES_PASSWORD: ${OED_DB_PASSWORD} # default postgres password that should be changed for security. volumes: - ./postgres-data:/var/lib/postgresql/data/pgdata healthcheck: @@ -29,28 +29,28 @@ services: web: # Configuration variables for the app. environment: - - OED_PRODUCTION=yes - - OED_SERVER_PORT=3000 - - OED_DB_USER=oed - - OED_DB_DATABASE=oed - - OED_DB_TEST_DATABASE=oed_testing - - OED_DB_PASSWORD=opened - - OED_DB_HOST=database # Docker will set this hostname - - OED_DB_PORT=5432 - - 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=someone@example.com # 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=mydomain@example.com # The email address that the email will come from - - OED_MAIL_TO=someone@example.com # 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 + OED_PRODUCTION: "yes" + 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: someone@example.com # 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: mydomain@example.com # The email address that the email will come from + OED_MAIL_TO: someone@example.com # 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. + 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. From d203d68fd78788e74878942dadaa4a30a4252ff5 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 20:57:51 -0700 Subject: [PATCH 11/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 6 +++--- docker-compose.ci.yml | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index fa56e3eb1..1cbf516ef 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -20,12 +20,12 @@ jobs: - name: Create .env file for Docker Compose run: | cat < .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_DB_TEST_DATABASE=${{ secrets.OED_DB_TEST_DATABASE }} - OED_DB_USER=${{ secrets.OED_DB_USER }} - OED_SERVER_PORT=${{ secrets.OED_SERVER_PORT }} OED_TOKEN_SECRET=${{ secrets.OED_TOKEN_SECRET }} EOF diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 5ef1711a8..aca78590a 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -13,7 +13,10 @@ services: environment: # Custom PGDATA per recommendations from official Docker page PGDATA: /var/lib/postgresql/data/pgdata - POSTGRES_PASSWORD: ${OED_DB_PASSWORD} # default postgres password that should be changed for security. + POSTGRES_USER: ${OED_DB_USER} + POSTGRES_PASSWORD: ${OED_DB_PASSWORD} + # Create the “test” database that your tests actually target + POSTGRES_DB: ${OED_DB_TEST_DATABASE} volumes: - ./postgres-data:/var/lib/postgresql/data/pgdata healthcheck: From 8dce2c14d7fe43e94ab5c83934b3350de14939d7 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 21:03:34 -0700 Subject: [PATCH 12/27] Changed the GitHub secrets. --- docker-compose.ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index aca78590a..ed04916d2 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -14,9 +14,6 @@ services: # Custom PGDATA per recommendations from official Docker page PGDATA: /var/lib/postgresql/data/pgdata POSTGRES_USER: ${OED_DB_USER} - POSTGRES_PASSWORD: ${OED_DB_PASSWORD} - # Create the “test” database that your tests actually target - POSTGRES_DB: ${OED_DB_TEST_DATABASE} volumes: - ./postgres-data:/var/lib/postgresql/data/pgdata healthcheck: @@ -32,7 +29,7 @@ services: web: # Configuration variables for the app. environment: - OED_PRODUCTION: "yes" + OED_PRODUCTION: "no" OED_SERVER_PORT: ${OED_SERVER_PORT} OED_DB_USER: ${OED_DB_USER} OED_DB_DATABASE: ${OED_DB_DATABASE} From 21c212d647292839722518c24f91ca04de4bc8e3 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 21:07:20 -0700 Subject: [PATCH 13/27] Changed the GitHub secrets. --- docker-compose.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index ed04916d2..87bebc844 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -29,7 +29,7 @@ services: web: # Configuration variables for the app. environment: - OED_PRODUCTION: "no" + OED_PRODUCTION: "yes" OED_SERVER_PORT: ${OED_SERVER_PORT} OED_DB_USER: ${OED_DB_USER} OED_DB_DATABASE: ${OED_DB_DATABASE} From 8e3379119e85c85d79c4accdf24c0fbe2cbe8f29 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 21:09:44 -0700 Subject: [PATCH 14/27] Changed the GitHub secrets. --- docker-compose.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 87bebc844..0b1ab7ec3 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -13,7 +13,7 @@ services: environment: # Custom PGDATA per recommendations from official Docker page PGDATA: /var/lib/postgresql/data/pgdata - POSTGRES_USER: ${OED_DB_USER} + POSTGRES_PASSWORD: ${OED_DB_PASSWORD} volumes: - ./postgres-data:/var/lib/postgresql/data/pgdata healthcheck: From 9ab1afdafe62eb3e8a991d35d5558ec00872b305 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 21:20:21 -0700 Subject: [PATCH 15/27] Changed the GitHub secrets. --- .github/workflows/build.yml | 4 ++-- docker-compose.ci.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 499eeef3d..b9db7bf48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,8 +28,8 @@ jobs: postgres: image: postgres env: - POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} - POSTGRES_DB: ${{ secrets.POSTGRES_DB }} + POSTGRES_PASSWORD: ${{ secrets.OED_DB_PASSWORD }} + POSTGRES_DB: ${{ secrets.OED_DB_TEST_DATABASE }} options: >- --health-cmd pg_isready --health-interval 10s diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 0b1ab7ec3..edc0018db 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -13,7 +13,7 @@ services: environment: # Custom PGDATA per recommendations from official Docker page PGDATA: /var/lib/postgresql/data/pgdata - POSTGRES_PASSWORD: ${OED_DB_PASSWORD} + POSTGRES_PASSWORD: pleaseChange volumes: - ./postgres-data:/var/lib/postgresql/data/pgdata healthcheck: From 2ba008555fb357e3e12815f29b09e4b821af26f6 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Fri, 9 May 2025 21:25:08 -0700 Subject: [PATCH 16/27] Changed the GitHub secrets. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9db7bf48..e7c0462b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: 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.POSTGRES_PASSWORD }} + 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. From 9332c95891f162e847febec2ed3e32523591f33d Mon Sep 17 00:00:00 2001 From: knakatasf Date: Sat, 10 May 2025 10:25:52 -0700 Subject: [PATCH 17/27] Changed the GitHub secrets. --- docker-compose.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index edc0018db..0b1ab7ec3 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -13,7 +13,7 @@ services: environment: # Custom PGDATA per recommendations from official Docker page PGDATA: /var/lib/postgresql/data/pgdata - POSTGRES_PASSWORD: pleaseChange + POSTGRES_PASSWORD: ${OED_DB_PASSWORD} volumes: - ./postgres-data:/var/lib/postgresql/data/pgdata healthcheck: From 9ca9b12885bb492a268af64a55efc19177a1bde4 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Wed, 21 May 2025 16:09:43 -0700 Subject: [PATCH 18/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 1cbf516ef..ada60e2c6 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -2,9 +2,9 @@ name: Build Docker on: pull_request: - branches: [development] + branches: [ development ] push: - branches: [development] + branches: [ development ] jobs: run-docker-checks-tests: @@ -34,14 +34,9 @@ jobs: docker compose -f docker-compose.ci.yml build docker compose -f docker-compose.ci.yml up -d - - name: Wait for DB & Web to be healthy + - name: Wait for database to be healthy run: docker compose -f docker-compose.ci.yml ps - - name: Install dependencies inside the web container - run: | - docker compose -f docker-compose.ci.yml run --rm web \ - sh -c "npm ci" - # - name: Run lint & type checks # run: | # docker compose -f docker-compose.ci.yml run --rm web \ From c40c8a1efcd22130aeb5cc1b8a928cd764caf19b Mon Sep 17 00:00:00 2001 From: knakatasf Date: Wed, 21 May 2025 16:14:19 -0700 Subject: [PATCH 19/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index ada60e2c6..b64cac1db 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -45,7 +45,7 @@ jobs: - name: Run unit & integration tests run: | docker compose -f docker-compose.ci.yml run --rm web \ - sh -c "npm test" + sh -c "npm ci && npm test" - name: Tear down if: always() From 0cc924ccafb7b1f356b52513b65a2da83d291acf Mon Sep 17 00:00:00 2001 From: knakatasf Date: Wed, 21 May 2025 16:44:51 -0700 Subject: [PATCH 20/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index b64cac1db..3d0c6d481 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -37,10 +37,10 @@ jobs: - name: Wait for database to be healthy run: docker compose -f docker-compose.ci.yml ps -# - name: Run lint & type checks -# run: | -# docker compose -f docker-compose.ci.yml run --rm web \ -# sh -c "npm run check:header && npm run check:typescript && npm run check:types && npm run check:lint" + - name: Run lint & type checks + run: | + docker compose -f docker-compose.ci.yml run --rm web \ + sh -c "npm ci && npm run check:header && npm run check:typescript && npm run check:types && npm run check:lint" - name: Run unit & integration tests run: | From 57f825c9b389324044940aab8738a4e2111b2109 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Wed, 21 May 2025 16:50:40 -0700 Subject: [PATCH 21/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 3d0c6d481..cb9219738 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -37,10 +37,17 @@ jobs: - name: Wait for database to be healthy run: docker compose -f docker-compose.ci.yml ps - - name: Run lint & type checks + - name: Install deps & run checks run: | docker compose -f docker-compose.ci.yml run --rm web \ - sh -c "npm ci && npm run check:header && npm run check:typescript && npm run check:types && npm run check:lint" + 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 & integration tests run: | From f24ddf409247b40c08cf0aabfc7cdde3ee2bbd42 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Wed, 21 May 2025 16:57:05 -0700 Subject: [PATCH 22/27] Changed the GitHub secrets. --- .github/workflows/build-docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index cb9219738..f2d6005c0 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -49,6 +49,7 @@ jobs: npm run check:lint \ " + - name: Run unit & integration tests run: | docker compose -f docker-compose.ci.yml run --rm web \ From b40443b5b1b706a36da3497fabf9464a7f2409a8 Mon Sep 17 00:00:00 2001 From: knakatasf Date: Thu, 22 May 2025 15:50:09 -0700 Subject: [PATCH 23/27] Added comments --- .github/workflows/build-docker.yml | 14 +++++++++++--- .github/workflows/build.yml | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index f2d6005c0..eb8ba4897 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -14,9 +14,12 @@ jobs: - 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 < .env @@ -29,15 +32,21 @@ jobs: 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 - - name: Install deps & run checks + # 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 "\ @@ -49,8 +58,7 @@ jobs: npm run check:lint \ " - - - name: Run unit & integration tests + - name: Run unit and integration tests run: | docker compose -f docker-compose.ci.yml run --rm web \ sh -c "npm ci && npm test" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e7c0462b5..2b0945f27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,7 @@ on: jobs: run-checks-tests: env: + # ${{ 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 }} @@ -28,6 +29,7 @@ jobs: postgres: image: postgres env: + # ${{ 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: >- @@ -72,6 +74,7 @@ jobs: - name: Connect to PostgreSQL run: node client.js env: + # ${{ secrets }} is saved in Repository secrets (Repo -> Settings -> Secrets and variables -> Actions) POSTGRES_HOST: ${{ secrets.OED_DB_HOST }} POSTGRES_PORT: ${{ secrets.OED_DB_PORT }} From 3d2854261c5a060bc09bde7a94e007d2553861bf Mon Sep 17 00:00:00 2001 From: knakatasf Date: Thu, 22 May 2025 17:00:16 -0700 Subject: [PATCH 24/27] Added comments --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index eb8ba4897..05116d303 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -45,7 +45,7 @@ jobs: # 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. + # Git denies 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 \ From f1a71063b5a56073221dffb274cc8b51bea72edd Mon Sep 17 00:00:00 2001 From: knakatasf Date: Thu, 22 May 2025 17:05:57 -0700 Subject: [PATCH 25/27] Added comments --- .github/workflows/build-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 05116d303..eb8ba4897 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -45,7 +45,7 @@ jobs: # 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 denies the execution if the mounted volume (/usr/src/app) is owned by a different user. + # 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 \ From 5f8a7fc375c9f130a23dbc81746c00bc8e144cbc Mon Sep 17 00:00:00 2001 From: knakatasf Date: Thu, 22 May 2025 17:23:14 -0700 Subject: [PATCH 26/27] Added comments --- docker-compose.ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 0b1ab7ec3..f64719f9b 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -29,7 +29,7 @@ services: web: # Configuration variables for the app. environment: - OED_PRODUCTION: "yes" + OED_PRODUCTION: "no" OED_SERVER_PORT: ${OED_SERVER_PORT} OED_DB_USER: ${OED_DB_USER} OED_DB_DATABASE: ${OED_DB_DATABASE} From 7c9962b4b158553301f3af23a968139f52c0f04a Mon Sep 17 00:00:00 2001 From: knakatasf Date: Wed, 18 Jun 2025 20:19:29 -0700 Subject: [PATCH 27/27] CI test --- .github/workflows/build-docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index eb8ba4897..82fd768ff 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -32,6 +32,7 @@ jobs: OED_TOKEN_SECRET=${{ secrets.OED_TOKEN_SECRET }} EOF + # Build Docker images and run the containers -> integration smoke test - name: Build & start containers run: |