Skip to content

Commit

Permalink
add westerveltco/setup-ci-action composite workflow (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas authored Feb 21, 2024
1 parent 0060125 commit bd00852
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 71 deletions.
7 changes: 6 additions & 1 deletion src/django_twc_project/.github/workflows/deploy.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ on:

concurrency: production

env:
CI: True
FORCE_COLOR: 1
PYTHON_VERSION: "{{ python_version }}"

jobs:
bumpver:
runs-on: ubuntu-latest
Expand All @@ -20,7 +25,7 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "{{ python_version }}"
python-version: ${{ env.PYTHON_VERSION }}

- name: Install bumpver
run: |
Expand Down
87 changes: 17 additions & 70 deletions src/django_twc_project/.github/workflows/test.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,18 @@ concurrency:
group: {% raw %}${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}{% endraw %}

env:
FORCE_COLOR: 1
CI: True
FORCE_COLOR: 1
NODE_VERSION: "{{ node_version }}"
PYTHON_REQUIREMENTS: requirements.txt{%- for requirements_filename in extra_requirements_files.split(',') %},{{ requirements_filename }}.txt{% if not forloop.last %},{% endif %}{%- endfor %}
PYTHON_VERSION: "{{ python_version }}"

permissions:
contents: read

jobs:
setup:
runs-on: ubuntu-latest
outputs:
cache-dir: {% raw %}${{ steps.pip-cache.outputs.dir }}{% endraw %}
steps:
- uses: actions/setup-python@v5
with:
python-version: "{{ python_version }}"

- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT

test:
runs-on: ubuntu-latest
needs: setup
services:
postgres:
image: {{ postgres_docker_image }}:{{ postgres_docker_version }}
Expand All @@ -55,24 +43,14 @@ jobs:
with:
persist-credentials: false

- uses: actions/setup-python@v5
with:
python-version: "{{ python_version }}"

- uses: actions/setup-node@v4
- uses: westerveltco/setup-ci-action@v0
with:
node-version: "{{ node_version }}"
node-version: ${% raw %}{{ env.NODE_VERSION }}{% endraw %}
python-version: ${% raw %}{{ env.PYTHON_VERSION }}{% endraw %}
python-requirements: ${% raw %}{{ env.PYTHON_REQUIREMENTS }}{% endraw %}

- uses: actions/cache@v4
with:
path: {% raw %}${{ needs.setup.outputs.cache-dir }}{% endraw %}
key: {% raw %}${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}{% endraw %}
restore-keys: |
{% raw %}${{ runner.os }}-pip-{% endraw %}

- name: Install dependencies
- name: Install system packages
env:
PIP_CACHE_DIR: {% raw %}${{ needs.setup.outputs.cache-dir }}{% endraw %}
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
Expand All @@ -91,12 +69,6 @@ jobs:
ttf-mscorefonts-installer \
{%- endif %}
build-essential
python -m pip install -U pip
python -m pip install --no-warn-script-location -r requirements.txt
{%- for requirements_filename in extra_requirements_files.split(',') %}
python -m pip install --no-warn-script-location -r {{ requirements_filename }}.txt
{%- endfor %}
npm install

- name: Run migrations
run: |
Expand Down Expand Up @@ -130,24 +102,17 @@ jobs:

types:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "{{ python_version }}"

- uses: actions/cache@v4
- uses: westerveltco/setup-ci-action@v0
with:
path: {% raw %}${{ needs.setup.outputs.cache-dir }}{% endraw %}
key: {% raw %}${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}{% endraw %}
restore-keys: |
{% raw %}${{ runner.os }}-pip-{% endraw %}
python-version: ${% raw %}{{ env.PYTHON_VERSION }}{% endraw %}
python-requirements: ${% raw %}{{ env.PYTHON_REQUIREMENTS }}{% endraw %}

- name: Install dependencies
- name: Install system packages
env:
PIP_CACHE_DIR: {% raw %}${{ needs.setup.outputs.cache-dir }}{% endraw %}
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
{%- if postgres_docker_image == 'postgis/postgis' %}
Expand All @@ -165,11 +130,6 @@ jobs:
ttf-mscorefonts-installer \
{%- endif %}
build-essential
python -m pip install -U pip
python -m pip install --no-warn-script-location -r requirements.txt
{%- for requirements_filename in extra_requirements_files.split(',') %}
python -m pip install --no-warn-script-location -r {{ requirements_filename }}.txt
{%- endfor %}

- name: Run mypy
env:
Expand All @@ -179,24 +139,16 @@ jobs:

checks:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "{{ python_version }}"

- uses: actions/cache@v4
- uses: westerveltco/setup-ci-action@v0
with:
path: {% raw %}${{ needs.setup.outputs.cache-dir }}{% endraw %}
key: {% raw %}${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }}{% endraw %}
restore-keys: |
{% raw %}${{ runner.os }}-pip-{% endraw %}
python-version: ${% raw %}{{ env.PYTHON_VERSION }}{% endraw %}
python-requirements: ${% raw %}{{ env.PYTHON_REQUIREMENTS }}{% endraw %}

- name: Install dependencies
env:
PIP_CACHE_DIR: {% raw %}${{ needs.setup.outputs.cache-dir }}{% endraw %}
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
Expand All @@ -215,11 +167,6 @@ jobs:
ttf-mscorefonts-installer \
{%- endif %}
build-essential
python -m pip install -U pip
python -m pip install --no-warn-script-location -r requirements.txt
{%- for requirements_filename in extra_requirements_files.split(',') %}
python -m pip install --no-warn-script-location -r {{ requirements_filename }}.txt
{%- endfor %}

- name: Run deployment checks
env:
Expand Down

0 comments on commit bd00852

Please sign in to comment.