Skip to content

Commit

Permalink
Fix make starter and add nightly build check (#384)
Browse files Browse the repository at this point in the history
* Wait for drupal container before trying to change its file permissions

* Also wait for traefik to come online to avoid a premature 404 before the setup is considered complete

* Refactor shared components of make (starter|starter_dev|production)

* Create test.yml

* Abandon Windows test support

* One test is better than zero I suppose :D

* notify slack on nightly build

* fix env

* Add mac OS support

* Remove mac OS support

* Update starter site package
  • Loading branch information
joecorall committed Apr 19, 2024
1 parent 897e090 commit 3f03d68
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 20 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Test
on:
push:
paths-ignore:
- '**/*.md'
schedule:
# UTC
- cron: '15 12 * * *'
env:
TERM: xterm-256color
jobs:
make:
permissions:
contents: read
runs-on: ${{ matrix.os }}
strategy:
matrix:
# TODO: someone with more windows chops please add windows test support
# os: [windows-latest, ubuntu-latest, macos-latest]
# TODO: keep an eye when macos-14+ (M1) support is available
os: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup make and secrets for Windows
if: matrix.os == 'windows-latest'
run: |
choco install mingw -y
echo "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" >> $GITHUB_PATH
cp sample.env .env <-- do not know what windows cp. COPY?
C:\Program Files\Git\bin\bash.exe ./build/scripts/check-secrets.sh yes
- name: init secrets
if: matrix.os != 'windows-latest'
run: |-
cp sample.env .env
./build/scripts/check-secrets.sh yes
shell: bash

- name: make starter
run: make starter
shell: bash

- name: check online
# TODO: what's a windows curl?
if: matrix.os != 'windows-latest'
run: |-
STATUS=$(curl -k \
-w '%{http_code}' -o /dev/null \
https://islandora.traefik.me/)
echo "Site check returned ${STATUS}"
if [ ${STATUS} -ne 200 ]; then
echo "Failed to bring up site"
exit 1
fi
- name: make build
run: make build
shell: bash

- name: make production
run: make production
shell: bash

- name: check online
# TODO: what's a windows curl?
if: matrix.os != 'windows-latest'
run: |-
STATUS=$(curl -k \
-w '%{http_code}' -o /dev/null \
https://islandora.traefik.me/)
echo "Site check returned ${STATUS}"
if [ ${STATUS} -ne 200 ]; then
echo "Failed to bring up site"
exit 1
fi
- name: Notify Slack on nightly test failure
if: failure() && github.event_name == 'schedule'
run: |-
curl -s -o /dev/null -XPOST $SLACK_WEBHOOK_URL -d '{
"text": "🚨 Scheduled job failed! Click to view the run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GitHub Actions Run>",
}'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
46 changes: 27 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ starter: generate-secrets
docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'cd /home/root; composer install'; \
fi
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter
docker compose up -d --remove-orphans
$(MAKE) compose-up
$(MAKE) starter-finalize ENVIRONMENT=starter


Expand All @@ -170,22 +170,14 @@ starter_dev: generate-secrets
docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'git clone -b main https://github.com/Islandora-Devops/islandora-starter-site /home/root;'; \
fi
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIRONMENT=starter_dev
docker compose up -d --remove-orphans
@echo "Wait for the /var/www/drupal directory to be available"
while ! docker compose exec -T drupal with-contenv bash -lc 'test -d /var/www/drupal'; do \
echo "Waiting for /var/www/drupal directory to be available..."; \
sleep 2; \
done
$(MAKE) compose-up
docker compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx /var/www/drupal/ ; su nginx -s /bin/bash -c "composer install"'
$(MAKE) starter-finalize ENVIRONMENT=starter_dev


.PHONY: production
production: generate-secrets
$(MAKE) download-default-certs
$(MAKE) -B docker-compose.yml
$(MAKE) pull
docker compose up -d --remove-orphans
production: init
$(MAKE) compose-up
docker compose exec -T drupal with-contenv bash -lc 'composer install; chown -R nginx:nginx .'
$(MAKE) drupal-database update-settings-php
docker compose exec -T drupal with-contenv bash -lc "drush si -y --existing-config minimal --account-pass '$(shell cat secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD)'"
Expand Down Expand Up @@ -575,13 +567,15 @@ login:
echo "=============================\n"


.PHONY: starter-init
starter-init: generate-secrets
.PHONY: init
init: generate-secrets
$(MAKE) download-default-certs
$(MAKE) -B docker-compose.yml
$(MAKE) pull
mkdir -p $(CURDIR)/codebase

.PHONY: starter-init
starter-init: init
mkdir -p $(CURDIR)/codebase

.PHONY: starter-finalize
starter-finalize:
Expand All @@ -591,10 +585,8 @@ starter-finalize:
docker compose exec -T drupal with-contenv bash -lc "drush -l $(SITE) user:role:add fedoraadmin admin"
MIGRATE_IMPORT_USER_OPTION=--userid=1 $(MAKE) hydrate
docker compose exec -T drupal with-contenv bash -lc 'drush -l $(SITE) migrate:import --userid=1 --tag=islandora'
#docker compose exec -T drupal with-contenv bash -lc 'chown -R `id -u`:nginx /var/www/drupal'
#docker compose exec -T drupal with-contenv bash -lc 'drush migrate:rollback islandora_defaults_tags,islandora_tags'
$(MAKE) login

$(MAKE) wait-for-drupal-locally

.PHONY: install
## Installs drupal site(s) using environment variables.
Expand Down Expand Up @@ -682,4 +674,20 @@ fix_masonry:
fix_views:
docker cp scripts/patch_views.sh $$(docker ps --format "{{.Names}}" | grep drupal):/var/www/drupal/patch_views.sh
docker compose exec -T drupal with-contenv bash -lc "bash /var/www/drupal/patch_views.sh ; rm /var/www/drupal/patch_views.sh ; drush cr"


.PHONY: compose-up
.SILENT: compose-up
compose-up:
docker compose up -d --remove-orphans
while ! docker compose exec -T drupal with-contenv bash -lc 'test -d /var/www/drupal'; do \
echo "Waiting for /var/www/drupal directory to be available..."; \
sleep 1; \
done

.PHONY: wait-for-drupal-locally
.SILENT: wait-for-drupal-locally
wait-for-drupal-locally:
while ! curl -s -o /dev/null -m 5 https://islandora.traefik.me/ ; do \
echo "Waiting for https://islandora.traefik.me to be available..."; \
sleep 1; \
done
2 changes: 1 addition & 1 deletion sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CUSTOM_IMAGE_TAG=latest

# Packagist repo to use when creating a site with make starter
# Change this if you want to build from a different codebase than the starter site
CODEBASE_PACKAGE=islandora/islandora-starter-site:1.2.0
CODEBASE_PACKAGE=islandora/islandora-starter-site:1.6.2

# Includes `traefik` as a service, if false assume we are sharing a traefik
# from another project.
Expand Down

0 comments on commit 3f03d68

Please sign in to comment.