From 7c37c89b1d44c1a9d3f176851c99d51de82cdaac Mon Sep 17 00:00:00 2001 From: sergerdn <64213648+sergerdn@users.noreply.github.com> Date: Mon, 9 Oct 2023 07:51:33 -0700 Subject: [PATCH 1/2] chore(dev-ops): add github actions --- .github/actions/linux/action.yaml | 44 +++++++++++++++ .github/workflows/python-tests.yml | 87 ++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 .github/actions/linux/action.yaml create mode 100644 .github/workflows/python-tests.yml diff --git a/.github/actions/linux/action.yaml b/.github/actions/linux/action.yaml new file mode 100644 index 0000000..b4d15ac --- /dev/null +++ b/.github/actions/linux/action.yaml @@ -0,0 +1,44 @@ +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: + - uses: actions/checkout@v3 + with: + lfs: true + + - 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 dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install dependencies with Poetry + shell: bash + run: | + mkdir ./dist && touch ./dist/README.md + poetry install --no-interaction + poetry run playwright install chromium --with-deps diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml new file mode 100644 index 0000000..323a49c --- /dev/null +++ b/.github/workflows/python-tests.yml @@ -0,0 +1,87 @@ +name: Python CI + +on: + push: + branches: [ "develop", "master" ] + pull_request: + branches: [ "develop", "master" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-22.04 # https://github.com/actions/runner-images#available-images + + steps: + - 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 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install dependencies with Poetry + run: | + mkdir ./dist && touch ./dist/README.md + poetry install --no-interaction --with dev,cmd,cmd-dev,docs + poetry run playwright install chromium --with-deps + + test: + needs: build + runs-on: ubuntu-22.04 + + steps: + - 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 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Install dependencies with Poetry + 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/ From 3c018b4ea3270a4882bd01f92b2501b461645782 Mon Sep 17 00:00:00 2001 From: sergerdn <64213648+sergerdn@users.noreply.github.com> Date: Mon, 9 Oct 2023 08:58:25 -0700 Subject: [PATCH 2/2] chore(github-actions): initial GitHub actions --- .github/actions/linux/action.yaml | 34 +++++++++-- .github/workflows/python-tests.yml | 91 +++++++++++++----------------- 2 files changed, 67 insertions(+), 58 deletions(-) diff --git a/.github/actions/linux/action.yaml b/.github/actions/linux/action.yaml index b4d15ac..1bfb1b4 100644 --- a/.github/actions/linux/action.yaml +++ b/.github/actions/linux/action.yaml @@ -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 @@ -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 \ No newline at end of file diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 323a49c..24478ba 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -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