Skip to content
Open
15 changes: 0 additions & 15 deletions .github/workflows/ci.yml

This file was deleted.

83 changes: 83 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: cicd

on:
push

env:
POSTGRES_DBNAME: postgres
POSTGRES_USER: postgres
POSTGRES_PWD: postgres
POSTGRES_HOST: 127.0.0.1
POSTGRES_PORT: 15434

jobs:
tests:
name: Django Tests
runs-on: ubuntu-latest

services:
postgres:
image: "postgres:15"
env:
POSTGRES_PASSWORD: ${{env.POSTGRES_PWD}}
POSTGRES_USER: ${{env.POSTGRES_USER}}
POSTGRES_DB: ${{env.POSTGRES_DBNAME}}
ports:
- 15434:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install and configure Poetry
run: |
INSTALL_PATH="$HOME/.local"
INSTALLATION_SCRIPT="$(mktemp)"
VIRTUALENVS_PATH="{cache-dir}/virtualenvs/#\~/$HOME"

curl -sSL https://install.python-poetry.org/ --output "$INSTALLATION_SCRIPT"

POETRY_HOME=$INSTALL_PATH python3 "$INSTALLATION_SCRIPT" --yes --version="1.3.2"

export PATH="/root/.local/bin:$PATH"

poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config virtualenvs.path "$VIRTUALENVS_PATH"

echo "VENV=.venv/bin/activate" >> "$GITHUB_ENV"

- name: Install Dependencies
run: |
export PATH="/root/.local/bin:$PATH"
poetry install --no-interaction

- name: Run Tests
run: |
source $VENV
cd sample_django_project && python manage.py test

deploy:
name: Deploy to prod
runs-on: ubuntu-latest

needs: tests

if: github.ref == 'refs/heads/master'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion docs/testing/7_github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:

### Results

Once you've commit-pushed your workflow, you can access the actions page of your repository. For example, this knowledge base, also has a continuous integration workflow defined, you can the actions page [here](https://github.com/runtimerevolution/python-knowledge-base/actions).
Once you've commit-pushed your workflow, you can access the actions page of your repository. For example, this knowledge base, also has a continuous integration workflow defined, you can see the actions page [here](https://github.com/runtimerevolution/python-knowledge-base/actions).

You can inspect each run individually and see if it's running correctly or not, or if the tests are accusing something wrong.

Expand Down