Update question1.md #1064
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: Build and Test | |
on: | |
push: | |
paths-ignore: | |
- 'docs/**' | |
- './README.md' | |
- './.gitignore' | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
buildandtest: | |
name: Build and Scan Image with Integration Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git clone the repository | |
uses: actions/checkout@v3 | |
- name: Add CKAN url to hosts | |
run: sudo echo "127.0.0.1 ckan-dev" | sudo tee -a /etc/hosts | |
- name: Add Minio url to hosts | |
run: sudo echo "127.0.0.1 minio" | sudo tee -a /etc/hosts | |
- name: Copy .env.example into .env | |
run: | | |
cp .env.example .env | |
- name: Install `Xvfb` and others to run browsers for end-to-end testing in local CI/CD simulations | |
if: ${{ env.ACT }} | |
run: sudo apt-get update && sudo apt-get install -y xvfb && npx playwright install-deps | |
- name: Set up Docker Containers | |
run: | | |
docker compose -f docker-compose.dev.yml --env-file .env.example up --build -d | |
- name: Create sysadmin API for Authorization | |
run: bash ./scripts/cypress_setup.sh | |
- name: Print Logs | |
run: docker compose -f docker-compose.dev.yml --env-file .env.example logs | |
continue-on-error: true | |
- name: Wait for ckan-tdc-dev to be healthy | |
run: | | |
echo "Waiting for ckan-tdc-dev to become healthy" | |
for i in {1..60}; do | |
health_status=$(docker inspect --format='{{.State.Health.Status}}' ckan-tdc-dev) | |
if [ "$health_status" == "healthy" ]; then | |
echo "ckan-tdc-dev is healthy" | |
break | |
elif [ "$health_status" == "unhealthy" ]; then | |
echo "ckan-tdc-dev is unhealthy, printing logs" | |
docker compose -f docker-compose.dev.yml logs ckan-tdc-dev | |
exit 1 | |
else | |
echo "Current health status: $health_status" | |
fi | |
sleep 5 | |
done | |
if [ "$health_status" != "healthy" ]; then | |
echo "ckan-tdc-dev did not become healthy in time" | |
docker compose -f docker-compose.dev.yml logs ckan-tdc-dev | |
exit 1 | |
fi | |
- name: Wait for ckan-tdc-db to be healthy | |
run: | | |
while ! docker exec ckan-tdc-db pg_isready -U ckandbuser -d ckandb; do | |
sleep 1 | |
done | |
- name: Run seeding geographies | |
run: docker exec ckan-tdc-dev sh -c "ckan -c ckan.ini create-default-geographies" | |
- name: Copy .env | |
run: cp .env.example .env | |
working-directory: ./frontend | |
- name: Run frontend tests 🧪 | |
uses: cypress-io/github-action@v6 | |
with: | |
install-command: npm install | |
build: npm run build | |
start: npm run start | |
wait-on: 'http://127.0.0.1:3000' | |
wait-on-timeout: 600 | |
command: npm run test | |
working-directory: ./frontend | |
- uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: /home/runner/work/ckan-docker-tdc-dev/ckan-docker-tdc-dev/integration-tests/cypress/screenshots | |
if-no-files-found: ignore | |
- name: Print Error Logs | |
if: failure() | |
run: docker compose -f docker-compose.dev.yml --env-file .env.example logs | |
- uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: Frontend screenshots | |
path: ./frontend/cypress/screenshots | |
if-no-files-found: ignore | |
- name: Tear down containers | |
if: failure() || success() | |
run: docker compose -f docker-compose.dev.yml --env-file .env.example down -v --remove-orphans |