From 202979ff32233222973627b5314c4be382423baa Mon Sep 17 00:00:00 2001 From: JohanGallardo Date: Thu, 2 May 2024 17:40:05 -0400 Subject: [PATCH 1/7] added workflow tests --- .github/workflows/app-tests.yaml | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/app-tests.yaml diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml new file mode 100644 index 0000000..0ef7556 --- /dev/null +++ b/.github/workflows/app-tests.yaml @@ -0,0 +1,42 @@ +name: Web App Test + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build_and_test: + runs-on: ubuntu-latest + + services: + mongo: + image: mongo + env: + MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGO_INITDB_ROOT_USERNAME }} + MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGO_INITDB_ROOT_PASSWORD }} + ports: + - 27017:27017 + + steps: + - uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build Docker Image + run: docker-compose build + + - name: Run Docker Containers + run: | + echo "MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }}" >> .env + echo "MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}" >> .env + docker-compose up -d + + - name: Run Tests + run: docker exec pytest + + - name: Clean up + if: always() + run: docker-compose down From ecab366c83ada8207c952029d10da7f033c0c7cf Mon Sep 17 00:00:00 2001 From: JohanGallardo Date: Thu, 2 May 2024 17:48:56 -0400 Subject: [PATCH 2/7] workflow environment variable fix --- .github/workflows/app-tests.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml index 0ef7556..530c8f2 100644 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -22,6 +22,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Set up Environment File + run: | + echo "MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }}" > .env + echo "MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}" >> .env + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -29,10 +34,7 @@ jobs: run: docker-compose build - name: Run Docker Containers - run: | - echo "MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }}" >> .env - echo "MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}" >> .env - docker-compose up -d + run: docker-compose up -d - name: Run Tests run: docker exec pytest From c13a855f48a0e669890c9819d08e03bfc4626f63 Mon Sep 17 00:00:00 2001 From: JohanGallardo Date: Thu, 2 May 2024 17:53:52 -0400 Subject: [PATCH 3/7] remove previous docker containers in action workflows --- .github/workflows/app-tests.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml index 530c8f2..2e734b2 100644 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -32,6 +32,9 @@ jobs: - name: Build Docker Image run: docker-compose build + + - name: Remove previous Docker containers + run: docker-compose down -v || true - name: Run Docker Containers run: docker-compose up -d From 3434cfeef624f157c9efdcdb1c7fc1ccc6c546f7 Mon Sep 17 00:00:00 2001 From: JohanGallardo Date: Thu, 2 May 2024 18:00:38 -0400 Subject: [PATCH 4/7] checking ports --- .github/workflows/app-tests.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml index 2e734b2..88861ef 100644 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -27,14 +27,17 @@ jobs: echo "MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }}" > .env echo "MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}" >> .env + - name: Remove previous Docker containers + run: docker-compose down -v || true + + - name: Check used ports + run: sudo netstat -tulnp | grep 27017 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Build Docker Image run: docker-compose build - - - name: Remove previous Docker containers - run: docker-compose down -v || true - name: Run Docker Containers run: docker-compose up -d From ed0c624d4ea2740aebd33c2910500ecbf6ac9bae Mon Sep 17 00:00:00 2001 From: JohanGallardo Date: Thu, 2 May 2024 18:04:54 -0400 Subject: [PATCH 5/7] enhanced removing of docker containers --- .github/workflows/app-tests.yaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml index 88861ef..d6dd132 100644 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -27,8 +27,11 @@ jobs: echo "MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }}" > .env echo "MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }}" >> .env - - name: Remove previous Docker containers - run: docker-compose down -v || true + - name: Force remove all Docker containers and networks + run: | + docker rm -f $(docker ps -aq) || true + docker network prune -f + docker volume prune -f - name: Check used ports run: sudo netstat -tulnp | grep 27017 From fe80c744399659c4ba7ea106aa8e3f82db5f980a Mon Sep 17 00:00:00 2001 From: JohanGallardo Date: Thu, 2 May 2024 18:06:06 -0400 Subject: [PATCH 6/7] remove check --- .github/workflows/app-tests.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml index d6dd132..b39b63c 100644 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -33,9 +33,6 @@ jobs: docker network prune -f docker volume prune -f - - name: Check used ports - run: sudo netstat -tulnp | grep 27017 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 From 325245c67687923cde36f9712f37cdbde3ce42d4 Mon Sep 17 00:00:00 2001 From: JohanGallardo Date: Thu, 2 May 2024 18:14:49 -0400 Subject: [PATCH 7/7] fixed tests --- .github/workflows/app-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/app-tests.yaml b/.github/workflows/app-tests.yaml index b39b63c..f7f3105 100644 --- a/.github/workflows/app-tests.yaml +++ b/.github/workflows/app-tests.yaml @@ -43,7 +43,7 @@ jobs: run: docker-compose up -d - name: Run Tests - run: docker exec pytest + run: docker exec 5-final-project-spring-2024-mjetteam_p5-web-app_1 pytest - name: Clean up if: always()