Skip to content

Commit

Permalink
CD: add caching, move py and node versions to env
Browse files Browse the repository at this point in the history
`npm ci` instead of `npm install` is more suitable for CI
many minor changes required for caching
  • Loading branch information
Privat33r-dev committed Apr 30, 2024
1 parent 1438c97 commit 9446722
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: cd

env:
PYTHON_VERSION: "3.10"

on:
push:
tags:
Expand Down Expand Up @@ -28,6 +31,9 @@ jobs:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'

- name: Install dependencies
run: pip install poetry
Expand Down
62 changes: 31 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,59 @@ on:
branches:
- main

permissions:
contents: read

env:
PYTHON_VERSION: "3.10"
NODE_VERSION: "20"
MODULE_NAME: clairvoyance
MIN_TEST_COV: 0
SERVER: http://localhost:4000

permissions:
contents: read

jobs:
unit-tests:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install
run: poetry install
- name: Run tests
run: |
source .venv/bin/activate
pytest --cov=$MODULE_NAME --cov-report=xml --cov-fail-under=$MIN_TEST_COV tests
system-tests:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install
run: poetry install
- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: tests/apollo-server/
- name: Install deps and run server
run: |
cd tests/apollo-server
npm install
cd tests/apollo-server/
npm ci
node src/index.js &
- name: Wait for server
run: |
Expand Down Expand Up @@ -96,16 +96,16 @@ jobs:
if: false
steps:
- uses: actions/checkout@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install
run: poetry install
- name: Run lint
if: always()
run: |
Expand Down

0 comments on commit 9446722

Please sign in to comment.