1515
1616permissions :
1717 contents : read # to fetch code (actions/checkout)
18+ packages : write # to write images to GitHub Container Registry (GHCR)
1819
1920jobs :
2021 # ###################################################
@@ -147,4 +148,115 @@ jobs:
147148 tags_flavor : suffix=-loadsql
148149 secrets :
149150 DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
150- DOCKER_ACCESS_TOKEN : ${{ secrets.DOCKER_ACCESS_TOKEN }}
151+ DOCKER_ACCESS_TOKEN : ${{ secrets.DOCKER_ACCESS_TOKEN }}
152+
153+ # ################################################################################
154+ # Test Deployment via Docker to ensure newly built images are working properly
155+ # ################################################################################
156+ docker-deploy :
157+ # Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace'
158+ if : github.repository == 'dspace/dspace'
159+ runs-on : ubuntu-latest
160+ # Must run after all major images are built
161+ needs : [dspace, dspace-test, dspace-cli, dspace-postgres-pgcrypto, dspace-solr]
162+ env :
163+ # Override defaults dspace.server.url because backend starts at http://127.0.0.1:8080
164+ dspace__P__server__P__url : http://127.0.0.1:8080/server
165+ # Enable all optional modules / controllers for this test deployment.
166+ # This helps check for errors in deploying these modules via Spring Boot
167+ iiif__P__enabled : true
168+ ldn__P__enabled : true
169+ oai__P__enabled : true
170+ rdf__P__enabled : true
171+ signposting__P__enabled : true
172+ sword__D__server__P__enabled : true
173+ swordv2__D__server__P__enabled : true
174+ # If this is a PR against main (default branch), use "latest".
175+ # Else if this is a PR against a different branch, used the base branch name.
176+ # Else if this is a commit on main (default branch), use the "latest" tag.
177+ # Else, just use the branch name.
178+ # NOTE: DSPACE_VER is used because our docker compose scripts default to using the "-test" image.
179+ DSPACE_VER : ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == github.event.repository.default_branch && 'latest') || (github.event_name == 'pull_request' && github.event.pull_request.base.ref) || (github.ref_name == github.event.repository.default_branch && 'latest') || github.ref_name }}
180+ # Docker Registry to use for Docker compose scripts below.
181+ # We use GitHub's Container Registry to avoid aggressive rate limits at DockerHub.
182+ DOCKER_REGISTRY : ghcr.io
183+ steps :
184+ # Checkout our codebase (to get access to Docker Compose scripts)
185+ - name : Checkout codebase
186+ uses : actions/checkout@v4
187+ # Download Docker image artifacts (which were just built by reusable-docker-build.yml)
188+ - name : Download Docker image artifacts
189+ uses : actions/download-artifact@v4
190+ with :
191+ # Download all amd64 Docker images (TAR files) into the /tmp/docker directory
192+ pattern : docker-image-*-linux-amd64
193+ path : /tmp/docker
194+ merge-multiple : true
195+ # Load each of the images into Docker by calling "docker image load" for each.
196+ # This ensures we are using the images just built & not any prior versions on DockerHub
197+ - name : Load all downloaded Docker images
198+ run : |
199+ find /tmp/docker -type f -name "*.tar" -exec docker image load --input "{}" \;
200+ docker image ls -a
201+ # Start backend using our compose script in the codebase.
202+ - name : Start backend in Docker
203+ run : |
204+ docker compose -f docker-compose.yml up -d
205+ sleep 10
206+ docker container ls
207+ # Create a test admin account. Load test data from a simple set of AIPs as defined in cli.ingest.yml
208+ - name : Load test data into Backend
209+ run : |
210+ docker compose -f docker-compose-cli.yml run --rm dspace-cli create-administrator -e test@test.edu -f admin -l user -p admin -c en
211+ docker compose -f docker-compose-cli.yml -f dspace/src/main/docker-compose/cli.ingest.yml run --rm dspace-cli
212+ # Verify backend started successfully.
213+ # 1. Make sure root endpoint is responding (check for dspace.name defined in docker-compose.yml)
214+ # 2. Also check /collections endpoint to ensure the test data loaded properly (check for a collection name in AIPs)
215+ - name : Verify backend is responding properly
216+ run : |
217+ result=$(wget -O- -q http://127.0.0.1:8080/server/api)
218+ echo "$result"
219+ echo "$result" | grep -oE "\"DSpace Started with Docker Compose\","
220+ result=$(wget -O- -q http://127.0.0.1:8080/server/api/core/collections)
221+ echo "$result"
222+ echo "$result" | grep -oE "\"Dog in Yard\","
223+ # Verify basic backend logging is working.
224+ # 1. Access the top communities list. Verify that the "Before request" INFO statement is logged
225+ # 2. Access an invalid endpoint (and ignore 404 response). Verify that a "status:404" WARN statement is logged
226+ - name : Verify backend is logging properly
227+ run : |
228+ wget -O/dev/null -q http://127.0.0.1:8080/server/api/core/communities/search/top
229+ logs=$(docker compose -f docker-compose.yml logs -n 5 dspace)
230+ echo "$logs"
231+ echo "$logs" | grep -o "Before request \[GET /server/api/core/communities/search/top\]"
232+ wget -O/dev/null -q http://127.0.0.1:8080/server/api/does/not/exist || true
233+ logs=$(docker compose -f docker-compose.yml logs -n 5 dspace)
234+ echo "$logs"
235+ echo "$logs" | grep -o "status:404 exception: The repository type does.not was not found"
236+ # Verify Handle Server can be stared and is working properly
237+ # 1. First generate the "[dspace]/handle-server" folder with the sitebndl.zip
238+ # 2. Start the Handle Server (and wait 20 seconds to let it start up)
239+ # 3. Verify logs do NOT include "Exception" in the text (as that means an error occurred)
240+ # 4. Check that Handle Proxy HTML page is responding on default port (8000)
241+ - name : Verify Handle Server is working properly
242+ run : |
243+ docker exec -i dspace /dspace/bin/make-handle-config
244+ echo "Starting Handle Server..."
245+ docker exec -i dspace /dspace/bin/start-handle-server
246+ sleep 20
247+ echo "Checking for errors in error.log"
248+ result=$(docker exec -i dspace sh -c "cat /dspace/handle-server/logs/error.log* || echo ''")
249+ echo "$result"
250+ echo "$result" | grep -vqz "Exception"
251+ echo "Checking for errors in handle-server.log..."
252+ result=$(docker exec -i dspace cat /dspace/log/handle-server.log)
253+ echo "$result"
254+ echo "$result" | grep -vqz "Exception"
255+ echo "Checking to see if Handle Proxy webpage is available..."
256+ result=$(wget -O- -q http://127.0.0.1:8000/)
257+ echo "$result"
258+ echo "$result" | grep -oE "Handle Proxy"
259+ # Shutdown our containers
260+ - name : Shutdown Docker containers
261+ run : |
262+ docker compose -f docker-compose.yml down
0 commit comments