From 2322e361e58cced8af4055c315a8d93164b67b8d Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Tue, 1 Apr 2025 17:10:26 +1100 Subject: [PATCH 1/4] workflows: update tests --- .github/workflows/docker_compose.yml | 6 +++--- .github/workflows/test.yml | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker_compose.yml b/.github/workflows/docker_compose.yml index 42fba32..3f810f1 100644 --- a/.github/workflows/docker_compose.yml +++ b/.github/workflows/docker_compose.yml @@ -1,4 +1,4 @@ -name: Pytest in docker compose +name: Tests in docker compose on: pull_request: @@ -17,11 +17,11 @@ jobs: mkdir tests_output chmod a+w tests_output - - name: Run docker-compose + - name: Setup docker-compose uses: hoverkraft-tech/compose-action@v2.0.1 with: compose-file: "docker-compose.yaml" - name: Execute tests in the running services run: | - docker compose run test + docker compose run test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a09a79a..9bba37b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Python +name: Tests on: pull_request: @@ -10,11 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python 3.10 + - name: Setup Python uses: actions/setup-python@v5 with: - python-version: '3.11' - cache: 'pip' + python-version: "3.11" + cache: "pip" - name: Install dependencies run: | python -m pip install --upgrade pip pytest pytest-mock @@ -23,4 +23,4 @@ jobs: echo "${{ github.workspace }}" >> $GITHUB_PATH - name: Test with pytest run: | - pytest --junitxml=pytest.xml + pytest --junitxml=pytest.xml From 7d7d7f7f440e0a57c3194f7485805e93549415b3 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Tue, 1 Apr 2025 17:18:52 +1100 Subject: [PATCH 2/4] workflows: deploy on releases and pushes to env branches (bug 1957532) --- .github/workflows/deploy.yml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b8202fa --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,52 @@ +name: Deployment + +on: + push: + branches: + - develop + - staging + - main + release: + types: + - published + +env: + IMAGE_NAME: git-hg-sync + GAR_LOCATION: us + GCP_PROJECT_ID: moz-fx-git-hg-sync-prod + GAR_REPOSITORY: git-hg-sync-prod + +jobs: + deploy: + runs-on: ubuntu-latest + environment: build + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: "0" + - uses: docker/setup-buildx-action@v2 + - id: gcp-auth + name: Google authentication + uses: google-github-actions/auth@v2 + with: + token_format: "access_token" + service_account: artifact-writer@${{ env.GCP_PROJECT_ID }}.iam.gserviceaccount.com + workload_identity_provider: ${{ vars.GCPV2_GITHUB_WORKLOAD_IDENTITY_PROVIDER }} + - name: Log in to the container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev + username: oauth2accesstoken + password: ${{ steps.gcp-auth.outputs.access_token }} + - name: Build and push image + uses: docker/build-push-action@v3 + with: + context: . + tags: | + ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max From 327936a5a9cc840e27e538571ea246083547ec55 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Tue, 1 Apr 2025 12:27:59 +1100 Subject: [PATCH 3/4] workflows: build docker-hub image on pushes to main (bug 1938985) --- .github/workflows/build.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c5acf47 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build + +on: + push: + branches: + - main + +env: + DOCKERHUB_REPO: mozillaconduit/git-hg-sync + DOCKER_USER: ${{ vars.DOCKERHUB_USERNAME }} + DOCKER_PASS: ${{ secrets.DOCKERHUB_TOKEN }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build the Docker image + run: docker build -t git-hg-sync . + - name: Tag the image + run: | + [[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] || exit 0 + docker tag "$DOCKERHUB_REPO" "$DOCKERHUB_REPO:${{ github.sha }}" + docker push "$DOCKERHUB_REPO:${{ github.sha }}" From 4f3e8d00fb52749165da687861881f5ec087b798 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Tue, 1 Apr 2025 12:49:40 +1100 Subject: [PATCH 4/4] REVERTME PRIOR TO MERGING --- .github/workflows/build.yml | 2 ++ .github/workflows/deploy.yml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c5acf47..698fbc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,8 @@ on: push: branches: - main + # XXX: remove before merging + pull_request: env: DOCKERHUB_REPO: mozillaconduit/git-hg-sync diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b8202fa..a234282 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,8 @@ on: release: types: - published + # XXX: remove before merging + pull_request: env: IMAGE_NAME: git-hg-sync @@ -46,7 +48,7 @@ jobs: with: context: . tags: | - ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }} + ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE_NAME }}:develop push: true cache-from: type=gha cache-to: type=gha,mode=max