Skip to content

Commit

Permalink
Make minor refactoring for CD tests
Browse files Browse the repository at this point in the history
 - Autoformat
 - Add names to steps
  • Loading branch information
Privat33r-dev committed Apr 30, 2024
1 parent 56a27e5 commit 1e3bf1f
Showing 1 changed file with 87 additions and 82 deletions.
169 changes: 87 additions & 82 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ 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

Expand All @@ -30,89 +30,94 @@ 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: ${{ 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
- 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@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- 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
- 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@v4
- name: Install and configure poetry
run: |
pipx install poetry
poetry config virtualenvs.in-project true
- 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
- 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

0 comments on commit 1e3bf1f

Please sign in to comment.