Refactor to use FastAPI #1635
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 | |
jobs: | |
lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- run: | | |
echo "PYTHON_VERSION=$(python -c 'import platform; print(platform.python_version())')" >> $GITHUB_ENV | |
- name: Install npm deps | |
run: npm install | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.3.2 | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ~/.virtualenvs | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v4 | |
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 | |
- name: Lint Python | |
run: make lint | |
test-unit: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | |
echo "PYTHON_VERSION=$(cat .python-version)" >> $GITHUB_ENV | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: "npm" | |
- run: | | |
echo "PYTHON_VERSION=$(python -c 'import platform; print(platform.python_version())')" >> $GITHUB_ENV | |
- name: Install npm deps | |
run: npm install | |
- name: Running ajv tests | |
run: make test-ajv | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.3.2 | |
virtualenvs-create: true | |
virtualenvs-in-project: false | |
virtualenvs-path: ~/.virtualenvs | |
- name: Cache Poetry virtualenv | |
uses: actions/cache@v4 | |
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 | |
- name: Running unit tests | |
run: make test-unit | |
docker-push: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Tag | |
run: | | |
CLEAN_TAG=$(echo "${{ github.event.pull_request.head.ref }}" | tr / -) | |
echo "TAG=$CLEAN_TAG" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
docker build -t onsdigital/eq-questionnaire-validator:$TAG . | |
docker build -f Dockerfile-ajv -t onsdigital/eq-questionnaire-validator:$TAG-ajv . | |
- name: Push | |
run: | | |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
echo "Pushing with tag [$TAG]" | |
docker push onsdigital/eq-questionnaire-validator:$TAG | |
echo "Pushing with tag [$TAG-ajv]" | |
docker push onsdigital/eq-questionnaire-validator:$TAG-ajv |