Bump nanoid from 3.3.7 to 3.3.8 #97
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: push | |
jobs: | |
run-tests: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
services: | |
docker: | |
image: docker:dind | |
options: --privileged | |
env: | |
FHIR_CONTAINER_NAME: 'node-fhir-server-mongo-fhir-1' | |
VERSION: '4_0_0' | |
PORT: '3000' | |
steps: | |
- uses: actions/[email protected] | |
- name: Create containers with docker compose | |
run: docker compose up -d | |
- name: Wait for application to be ready | |
run: | | |
# Wait up to a minute for the server to start | |
max_attempts=12 | |
attempt=0 | |
echo "Waiting for the application to be ready..." | |
while ! docker logs "${FHIR_CONTAINER_NAME}" 2>&1 | grep "Server is up and running!"; do | |
# Increment the attempt counter | |
attempt=$((attempt + 1)) | |
# Break out of the loop after too many attempts | |
if [ "$attempt" -ge "$max_attempts" ]; then | |
break | |
fi | |
echo "Waiting..." | |
sleep 5 | |
done | |
docker ps | |
- name: Extract Container IP Address | |
run: | | |
# Extract docker container IP address | |
echo "CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${FHIR_CONTAINER_NAME}")" >> $GITHUB_ENV | |
- name: Test curl request for patient metadata | |
run: | | |
# Perform GET request for metadata | |
response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ | |
-H "Content-Type: application/json" \ | |
"http://${CONTAINER_IP}:${PORT}/${VERSION}/metadata") | |
# Check if the HTTP status code is 200 | |
if [ "$response" -eq 200 ]; then | |
echo "Request successful with status code 200." | |
else | |
echo "Request failed with status code $response." | |
exit 1 | |
fi | |
- name: Test curl request to add new service | |
run: | | |
for filename_with_extension_and_path in sample_data/*.json; do | |
filename_with_extension="${filename_with_extension_and_path##*/}" | |
filename="${filename_with_extension%%.*}" | |
echo "Perform PUT request to add a new ${filename}" | |
response=$(curl -s -o /dev/null -w "%{http_code}" -X PUT \ | |
-T ${filename_with_extension_and_path} \ | |
-H "Content-Type: application/json" \ | |
"http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example_${filename}") | |
# Check if the HTTP status code is 200 | |
if [ "$response" -eq 200 ]; then | |
echo "Request ${filename} successful with status code 200." | |
else | |
echo "Request ${filename} failed with status code $response." | |
exit 1 | |
fi | |
done | |
- name: Test curl request for existing service | |
run: | | |
for filename_with_extension_and_path in sample_data/*.json; do | |
filename_with_extension="${filename_with_extension_and_path##*/}" | |
filename="${filename_with_extension%%.*}" | |
echo "Perform GET request get the newly added ${filename}" | |
response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ | |
-H "Content-Type: application/json" \ | |
"http://${CONTAINER_IP}:${PORT}/${VERSION}/${filename}/example_${filename}") | |
# Check if the HTTP status code is 200 | |
if [ "$response" -eq 200 ]; then | |
echo "Request ${filename} successful with status code 200." | |
else | |
echo "Request ${filename} failed with status code $response." | |
exit 1 | |
fi | |
done | |
- name: Test curl request for non-existing patient to fail | |
run: | | |
for filename_with_extension_and_path in sample_data/*.json; do | |
filename_with_extension="${filename_with_extension_and_path##*/}" | |
filename="${filename_with_extension%%.*}" | |
echo "Perform GET request for a non-existing ${filename}" | |
response=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ | |
-H "Content-Type: application/json" \ | |
"http://${CONTAINER_IP}:${PORT}/${VERSION}/Patient/missing_${filename}") | |
# Check if the HTTP status code is 200 | |
if [ "$response" -ne 200 ]; then | |
echo "Request ${filename} successful with status code $response (non 200)." | |
else | |
echo "Request ${filename} failed with undesired status code 200." | |
exit 1 | |
fi | |
done | |
- name: Shutdown containers with docker compose | |
run: docker compose down |