Skip to content

Commit

Permalink
chore(github-actions): initial GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
sergerdn committed Oct 9, 2023
1 parent 7c37c89 commit 3c018b4
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 58 deletions.
34 changes: 28 additions & 6 deletions .github/actions/linux/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ inputs:
runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
with:
lfs: true

- name: Checkout LFS objects
shell: bash
run: git lfs checkout
Expand All @@ -30,15 +26,41 @@ runs:
virtualenvs-in-project: true
installer-parallel: true

- name: Cache dependencies
- name: Cache python dependencies
uses: actions/cache@v3
id: poetry-cache
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Get installed Playwright version
id: playwright-version
shell: bash
run: |
echo "::set-output name=version::$(poetry show playwright | grep "version" | awk '{print $3}')"
- name: Cache playwright dependencies
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright/
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}

- name: Ensure python poetry installed
shell: bash
run: |
echo "playwright version: ${{ steps.playwright-version.outputs.version }}"
python --version
poetry --version
- name: Install dependencies with Poetry
shell: bash
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
mkdir ./dist && touch ./dist/README.md
poetry install --no-interaction
poetry run playwright install chromium --with-deps
- name: Install playwright dependencies with Poetry
shell: bash
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: poetry run playwright install chromium --with-deps
91 changes: 39 additions & 52 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,78 +10,65 @@ permissions:
contents: read

jobs:
build:
lint:
runs-on: ubuntu-22.04 # https://github.com/actions/runner-images#available-images

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3
with:
lfs: true

- name: Checkout LFS objects
run: git lfs checkout

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Cache dependencies
uses: actions/cache@v3
- name: Setup Python and Poetry
uses: ./.github/actions/linux
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
python-version: '3.11'

- name: Install dependencies with Poetry
- name: Lint with mypy and flake8
env:
FINGERPRINT_KEY: ${{ secrets.FINGERPRINT_KEY }}
run: |
mkdir ./dist && touch ./dist/README.md
poetry install --no-interaction --with dev,cmd,cmd-dev,docs
poetry run playwright install chromium --with-deps
poetry run mypy pybas_automation/ tests/
poetry run flake8 pybas_automation/ tests/
test:
needs: build
runs-on: ubuntu-22.04

needs: [ lint ]
runs-on: ubuntu-22.04 # https://github.com/actions/runner-images#available-images
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3
with:
lfs: true

- name: Checkout LFS objects
run: git lfs checkout

- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Setup Python and Poetry
uses: ./.github/actions/linux
with:
python-version: "3.11"
python-version: '3.11'

- name: Run tests with pytest
env:
FINGERPRINT_KEY: ${{ secrets.FINGERPRINT_KEY }}
run: |
mkdir ./dist && touch ./dist/README.md
poetry run pytest -vv --cov=pybas_automation --cov-report=html tests/
- name: Install Poetry
uses: snok/install-poetry@v1
poetry_build:
needs: [ lint, test ]
runs-on: ubuntu-22.04 # https://github.com/actions/runner-images#available-images
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
lfs: true

- name: Cache dependencies
uses: actions/cache@v3
- name: Setup Python and Poetry
uses: ./.github/actions/linux
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
python-version: '3.11'

- name: Install dependencies with Poetry
- name: Lint with mypy and flake8
run: |
mkdir ./dist && touch ./dist/README.md
poetry install --no-interaction --with dev,cmd,cmd-dev,docs
poetry run playwright install chromium --with-deps
- name: Run tests with pytest
env:
FINGERPRINT_KEY: ${{ secrets.FINGERPRINT_KEY }}
run: poetry run pytest -vv tests/
poetry check
poetry run python scripts/update_readme_links.py
poetry build

0 comments on commit 3c018b4

Please sign in to comment.