diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd6cce98b3..02d68ceaa4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,16 +59,30 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Determine Branch Name + id: branch_name + run: | + if [ "${{ github.event_name }}" = "push" ]; then + echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + fi + - name: Push dev run: | docker buildx create --use + + tags="-t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-latest-dev" + + if [ -n "${{ env.BRANCH_NAME }}" ]; then + tags="$tags -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dev" + fi + docker buildx build \ --cache-from ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dev \ --cache-from ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dev \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dev \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dev \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dev \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-latest-dev \ + $tags \ -f ./docker/Dockerfile \ --target dev \ --push \ @@ -160,10 +174,24 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Determine Branch Name + id: branch_name + run: | + if [ "${{ github.event_name }}" = "push" ]; then + echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + fi + - name: Push dist run: | docker buildx create --use + tags="-t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist \ + -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}" + + if [ -n "${{ env.BRANCH_NAME }}" ]; then + tags="$tags -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ env.BRANCH_NAME }}-latest-dist" + fi + # Base part of the command build_command="docker buildx build \ --progress=plain \ @@ -173,8 +201,7 @@ jobs: --cache-from ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dist \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-${{ github.sha }}-dist \ --cache-to ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:cache-core-latest-dist \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }}-dist \ - -t ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-${{ github.sha }} \ + $tags \ -f ./docker/Dockerfile \ --target dist \ --push ./" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000000..e1cf0389f6 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,53 @@ +name: Nightly E2E Tests + +on: + workflow_dispatch: + schedule: + # Run at 2:00 AM every day + - cron: '0 2 * * *' + +jobs: + e2e_tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: DockerHub login + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Pull Latest Docker Images + run: | + docker pull ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dist + docker pull ${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dev + + - name: Run Selenium Nightly E2E tests + run: | + dist_backend_image=${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dist \ + dev_backend_image=${{ vars.DOCKERHUB_ORGANIZATION }}/hope-support-images:core-develop-latest-dev \ + docker compose \ + -f ./deployment/docker-compose.selenium-night.yml \ + run selenium + + - name: Upload Nightly Test Artifacts + uses: actions/upload-artifact@v4 + if: always() + continue-on-error: true + with: + name: nightly-e2e-report + path: ./backend/report/ + retention-days: 5 + + - name: Upload Nightly Coverage to Codecov + uses: codecov/codecov-action@v4 + if: always() + continue-on-error: true + with: + files: ./backend/coverage.xml + flags: nightly-e2e + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true diff --git a/deployment/docker-compose.selenium-night.yml b/deployment/docker-compose.selenium-night.yml index ffe2d860b7..7d17e14278 100644 --- a/deployment/docker-compose.selenium-night.yml +++ b/deployment/docker-compose.selenium-night.yml @@ -2,7 +2,7 @@ version: '3.7' volumes: backend-web-app: services: - selenium-night: + selenium: stdin_open: true environment: - REDIS_INSTANCE=redis:6379