Skip to content

Use docker compose for building and running container (local and CI) (github action and circleCI) #1313

Use docker compose for building and running container (local and CI) (github action and circleCI)

Use docker compose for building and running container (local and CI) (github action and circleCI) #1313

name: Verify Docker Image
on:
pull_request:
branches:
- master
jobs:
docker_config_check:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- expected: { version: local, push: false }
input: { version: '', push: '' }
- expected: { version: version, push: true }
input: { version: version, push: true }
steps:
- uses: actions/checkout@v4
- name: Check Docker Compose (default)
id: default
env:
DOCKER_VERSION: ${{ matrix.input.version }}
DOCKER_PUSH: ${{ matrix.input.push }}
shell: bash
run: |
set -xue
config=$(make docker_compose_config)
# Expect image tag is correct
echo $config | grep -q "image: mozilla/addons-server:${{ matrix.expected.version }}"
# Expect docker push args are correct
if [[ ${{ matrix.expected.push }} == "true" ]]; then
echo $config | grep -q -- "--push"
echo $config | grep -v -q -- "--load"
else
echo $config | grep -v -q -- "--push"
echo $config | grep -q -- "--load"
fi
# Expect docker platform is correct
echo $config | grep -q -- "platform: linux/amd64"
echo $config | grep -q -- "\"platforms\": \[
\"linux/amd64\"
\]"
verify_docker_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: build
uses: ./.github/actions/build-docker
with:
target: development
- name: Create failure
id: failure
uses: ./.github/actions/run-docker
with:
image: ${{ steps.build.outputs.image }}
version: ${{ steps.build.outputs.version }}
run: |
exit 1
continue-on-error: true
- name: Verify failure
if: always()
run: |
if [ "${{ steps.failure.outcome }}" -ne "failure" ]; then
echo "Expected failure"
exit 1
fi
- name: Check (special characters in command)
uses: ./.github/actions/run-docker
with:
version: ${{ steps.build.outputs.version }}
run: |
echo 'this is a question?'
echo 'a * is born'
echo 'wow an array []'
- name: Manage py check
uses: ./.github/actions/run-docker
with:
version: ${{ steps.build.outputs.version }}
run: |
make check
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: build
uses: ./.github/actions/build-docker
with:
target: development
- name: Run Test
uses: ./.github/actions/run-docker
with:
version: ${{ steps.build.outputs.version }}
services: ''
run: |
pytest \
-n auto \
-m 'not es_tests and not needs_locales_compilation and not static_assets and not internal_routes_allowed' \
-v src/olympia/amo
locales:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Build Docker image
id: build
uses: ./.github/actions/build-docker
with:
target: development
- name: Extract Locales
uses: ./.github/actions/run-docker
with:
version: ${{ steps.build.outputs.version }}
compose_file: docker-compose.olympia.yml
run: |
make extract_locales
- name: Push Locales (dry-run)
shell: bash
run: |
if [[ ${{ github.event.pull_request.head.repo.fork}} == 'true' ]]; then
echo """
Github actions are not authorized to push from workflows triggered by forks.
We cannot verify if the l10n extraction push will work or not.
Please submit a PR from the base repository if you are modifying l10n extraction scripts.
"""
exit 0
fi
make push_locales ARGS="--dry-run"