Rollback db actions when connection invalidated #421
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 checks | |
on: pull_request | |
env: | |
SECRET_KEY: insecure_test_key | |
jobs: | |
run-image: | |
runs-on: ubuntu-20.04 | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_HOST_AUTH_METHOD: trust | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build image | |
run: DOCKER_BUILDKIT=1 docker build --tag ubuntu-com-security-api . | |
- name: Run image | |
run: | | |
docker run --env SECRET_KEY=insecure_secret_key --network host --env DATABASE_URL=postgresql://postgres@localhost:5432/postgres ubuntu-com-security-api & | |
sleep 1 | |
curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost/security/api/docs | |
run-dotrun: | |
runs-on: ubuntu-20.04 | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_HOST_AUTH_METHOD: trust | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dotrun | |
run: sudo pip3 install dotrun requests==2.31.0 # requests version is pinned to avoid breaking changes, can be removed once issue is resolved: https://github.com/docker/docker-py/issues/3256resolved: https://github.com/docker/docker-py/issues/3256 | |
- name: Install dependencies | |
run: | | |
sudo chmod -R 777 . | |
dotrun install | |
- name: Run dotrun | |
run: | | |
dotrun & | |
curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost:8030/security/api/docs | |
lint-python: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Node dependencies | |
run: yarn install | |
- name: Python dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
sudo pip3 install flake8 black | |
- name: Lint python | |
run: yarn lint-python | |
test-python: | |
runs-on: ubuntu-20.04 | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: pw | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install requirements | |
run: | | |
sudo apt-get update && sudo apt-get install --yes python3-setuptools | |
sudo pip3 install -r requirements.txt | |
- name: Install dependencies | |
run: sudo pip3 install coverage | |
- name: Install node dependencies | |
run: yarn install --immutable | |
- name: Run tests with coverage | |
run: | | |
TEST_DATABASE_URL=postgresql://postgres:pw@localhost:5432/postgres coverage run --source=. -m unittest discover tests | |
bash <(curl -s https://codecov.io/bash) -cF python | |
check-inclusive-naming: | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Check inclusive naming | |
uses: canonical-web-and-design/inclusive-naming@main | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
reporter: github-pr-review | |
fail-on-error: true |