Update runner to use poetry package manager #10885
Workflow file for this run
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: PR | |
on: | |
pull_request: | |
branches: | |
- "main" | |
- "branch-v*" | |
- "bug-fix-*" | |
- "feature-*" | |
concurrency: | |
group: '${{ github.head_ref }}' | |
cancel-in-progress: true | |
jobs: | |
python-dependencies: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.7.1 | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ~/.virtualenvs | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v3 | |
id: cache-virtualenv | |
with: | |
path: ~/.virtualenvs | |
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-virtualenvs-${{ hashFiles('poetry.lock') }} | |
- name: Install virtual environment | |
run: | | |
sudo apt-get install libsnappy-dev | |
poetry install --no-interaction | |
node-dependencies: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file : ".nvmrc" | |
cache: "npm" | |
- name: Install npm deps | |
run: npm install | |
lint: | |
needs: [python-dependencies, node-dependencies] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- name: Write app version | |
run: printf "${{ github.event.pull_request.head.sha }}" > .application-version | |
- name: Install poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version : 1.7.1 | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ~/.virtualenvs | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v3 | |
id: cache-virtualenv | |
with: | |
path: ~/.virtualenvs | |
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-virtualenvs-${{ hashFiles('poetry.lock') }} | |
- name: Install virtual environment | |
if: steps.cache-virtualenv.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction | |
- name: Compile translations | |
run: make translate | |
- name: Running translation tests | |
run: poetry run python -m scripts.extract_translation_templates --test | |
- name: Python linting | |
run: make lint-python | |
- name: Install npm deps | |
run: npm install | |
- name: Functional tests spec lint | |
run: ./scripts/lint_functional_test_specs.sh | |
- name: Javascript linting | |
run: make lint-js | |
test-unit: | |
needs: python-dependencies | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install apt dependencies | |
run: | | |
sudo apt-get install libsnappy-dev libgconf-2-4 jq | |
# Install wkthtmltopdf with patched Qt | |
sudo apt-get install -y xfonts-base xfonts-75dpi | |
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb | |
sudo dpkg -i wkhtmltox_0.12.6-1.bionic_amd64.deb | |
- name: Write app version | |
run: printf "${{ github.event.pull_request.head.sha }}" > .application-version | |
- name: Install poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.7.1 | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ~/.virtualenvs | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v3 | |
id: cache-virtualenv | |
with: | |
path: ~/.virtualenvs | |
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-virtualenvs-${{ hashFiles('poetry.lock') }} | |
- name: Install Dependencies | |
if: steps.cache-virtualenv.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction | |
- name: Load templates | |
run: make load-design-system-templates | |
- name: Compile translations | |
run: make translate | |
- name: Link env vars | |
run: ln -sf .development.env .env | |
- name: Load .env File | |
uses: xom9ikk/dotenv@v2 | |
- name: Running unit tests | |
run: | |
make test-unit | |
validate-schemas: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Run validator | |
run: ./scripts/run_validator.sh | |
- name: Running schema tests | |
run: make validate-test-schemas | |
test-functional: | |
needs: [python-dependencies, node-dependencies] | |
strategy: | |
matrix: | |
suite: [ timeout_modal_expired, timeout_modal_extended, timeout_modal_extended_new_window, features, general, components ] | |
runs-on: ubuntu-22.04 | |
env: | |
EQ_RUN_FUNCTIONAL_TESTS_HEADLESS: True | |
# :TODO: Revisit & update when 2 instances can be used without adverse effects | |
EQ_FUNCTIONAL_TEST_MAX_INSTANCES: 1 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- run: | | |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.7.1 | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ~/.virtualenvs | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v3 | |
id: cache-virtualenv | |
with: | |
path: ~/.virtualenvs | |
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-virtualenvs-${{ hashFiles('poetry.lock') }} | |
- name: Install virtual environment | |
if: steps.cache-virtualenv.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction | |
- name: Install npm deps | |
run: npm install | |
- name: Docker compose | |
run: docker-compose --version && RUNNER_ENV_FILE=.functional-tests.env docker-compose up --build -d | |
- name: Functional tests | |
run: make test-functional-suite SUITE=${{ matrix.suite }} | |
- name: Docker compose shutdown | |
run: RUNNER_ENV_FILE=.functional-tests.env docker-compose kill | |
docker-push: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set Tag and SHA | |
run: | | |
CLEAN_TAG=$(echo "${{ github.event.pull_request.head.ref }}" | tr / -) | |
echo "TAG=$CLEAN_TAG" >> $GITHUB_ENV | |
echo "SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV | |
- name: Write app version | |
run: | | |
echo "Writing SHA $SHA to .application_version" | |
printf $SHA > .application-version | |
- name: Build | |
run: > | |
docker build -t onsdigital/eq-questionnaire-runner:$TAG | |
-t ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-runner:$TAG . | |
- name: Push to Docker Hub | |
run: | | |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
echo "Pushing to DockerHub with tag $TAG" | |
docker push onsdigital/eq-questionnaire-runner:$TAG | |
- name: Push to GAR | |
env: | |
GAR_SERVICE_KEY: ${{ secrets.GAR_SERVICE_KEY }} | |
run: | | |
echo $GAR_SERVICE_KEY | docker login -u _json_key --password-stdin https://${{ secrets.GAR_LOCATION }} | |
gcloud auth configure-docker ${{ secrets.GAR_LOCATION }} | |
echo "Pushing to GAR with tag $TAG" | |
docker push ${{ secrets.GAR_LOCATION }}/${{ secrets.GAR_PROJECT_ID }}/docker-images/eq-questionnaire-runner:$TAG |