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

chore(dev-ops): add github actions #5

Merged
merged 2 commits into from
Oct 9, 2023
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
66 changes: 66 additions & 0 deletions .github/actions/linux/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 'Setup Python and Poetry.'
description: 'Set up Python, install Poetry, cache dependencies, and install them with Poetry.'

inputs:
python-version:
description: 'Version of Python to use.'
required: true
default: '3.11'

runs:
using: 'composite'
steps:
- name: Checkout LFS objects
shell: bash
run: git lfs checkout

- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}

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

- 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

- name: Install playwright dependencies with Poetry
shell: bash
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: poetry run playwright install chromium --with-deps
74 changes: 74 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Python CI

on:
push:
branches: [ "develop", "master" ]
pull_request:
branches: [ "develop", "master" ]

permissions:
contents: read

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

- name: Setup Python and Poetry
uses: ./.github/actions/linux
with:
python-version: '3.11'

- name: Lint with mypy and flake8
env:
FINGERPRINT_KEY: ${{ secrets.FINGERPRINT_KEY }}
run: |
mkdir ./dist && touch ./dist/README.md
poetry run mypy pybas_automation/ tests/
poetry run flake8 pybas_automation/ tests/

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

- name: Setup Python and Poetry
uses: ./.github/actions/linux
with:
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/

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:
lfs: true

- name: Setup Python and Poetry
uses: ./.github/actions/linux
with:
python-version: '3.11'

- name: Lint with mypy and flake8
run: |
mkdir ./dist && touch ./dist/README.md
poetry check
poetry run python scripts/update_readme_links.py
poetry build
Loading