Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CD action versions and add poetry and npm caching #85

Merged
merged 4 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ name: cd
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- "v[0-9]+.[0-9]+.[0-9]+"

env:
PYTHON_VERSION: "3.10"

permissions:
contents: read
Expand All @@ -16,18 +19,28 @@ jobs:
contents: write

steps:
- uses: actions/checkout@v3
- uses: softprops/action-gh-release@v1
- name: Checkout
uses: actions/checkout@v4

- name: Version release on Github
uses: softprops/action-gh-release@v2
with:
make_latest: "true"

pypi-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-python@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"

- name: Install dependencies
run: pip install poetry
- name: Install poetry
run: pipx install poetry

- name: Setup poetry
run: |
Expand All @@ -39,15 +52,15 @@ jobs:
source .venv/bin/activate
poetry build

- name: Upload package
- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}

docker-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v2
Expand All @@ -57,7 +70,7 @@ jobs:

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -66,8 +79,8 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/clairvoyance
- name: Build and push

- name: Build container and push it to Docker Hub
id: docker_build
uses: docker/build-push-action@v3
with:
Expand All @@ -77,6 +90,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
179 changes: 92 additions & 87 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,116 +3,121 @@ name: tests
on:
push:
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- "README.md"
- "LICENSE"
- ".gitignore"
branches:
- main
pull_request:
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- "README.md"
- "LICENSE"
- ".gitignore"
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@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run tests
run: |
source .venv/bin/activate
pytest --cov=$MODULE_NAME --cov-report=xml --cov-fail-under=$MIN_TEST_COV tests
- name: Checkout
uses: actions/checkout@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Setup poetry
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@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install deps and run server
run: |
cd tests/apollo-server
npm install
node src/index.js &
- name: Wait for server
run: |
for i in {0..10}; do
echo "Sleep for 1 second ..."
sleep 1
if curl -s -o /dev/null "$SERVER"; then
echo "$SERVER returned HTTP response!"
break
fi
if [ $i -eq 10 ]; then
echo "Server did not respond after 10 seconds!"
exit 1
fi
done
- name: Test with pytest
run: |
source .venv/bin/activate
python -m unittest tests/system.py
- name: Checkout
uses: actions/checkout@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Setup poetry
run: poetry install
- uses: actions/setup-node@v4
with:
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 ci
node src/index.js &
- name: Wait for server
run: |
for i in {0..10}; do
echo "Sleep for 1 second ..."
sleep 1
if curl -s -o /dev/null "$SERVER"; then
echo "$SERVER returned HTTP response!"
break
fi
if [ $i -eq 10 ]; then
echo "Server did not respond after 10 seconds!"
exit 1
fi
done
- name: Test with pytest
run: |
source .venv/bin/activate
python -m unittest tests/system.py

lint:

runs-on: ubuntu-latest

if: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
- name: Setup poetry
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run lint
if: always()
run: |
source .venv/bin/activate
isort -m 9 --line-length 160 $MODULE_NAME tests --check-only
pylint --load-plugins pylint_quotes $MODULE_NAME tests
docformatter --wrap-summaries 160 --wrap-descriptions 160 -cr $MODULE_NAME tests
yapf -rd $MODULE_NAME tests
mypy -V
mypy $MODULE_NAME tests
- name: Checkout
uses: actions/checkout@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- name: Setup poetry
run: poetry install
- name: Run lint
if: always()
run: |
source .venv/bin/activate
isort -m 9 --line-length 160 $MODULE_NAME tests --check-only
pylint --load-plugins pylint_quotes $MODULE_NAME tests
docformatter --wrap-summaries 160 --wrap-descriptions 160 -cr $MODULE_NAME tests
yapf -rd $MODULE_NAME tests
mypy -V
mypy $MODULE_NAME tests