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..4874c60 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -10,78 +10,64 @@ 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 + - name: Setup Python and Poetry + uses: ./.github/actions/linux with: - python-version: "3.11" + 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/ - - name: Install Poetry - uses: snok/install-poetry@v1 + build: + 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 + poetry check + poetry run python scripts/update_readme_links.py + poetry build test: - needs: build - runs-on: ubuntu-22.04 - + needs: [ lint, build ] + 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') }} - - - 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 + python-version: '3.11' - name: Run tests with pytest env: FINGERPRINT_KEY: ${{ secrets.FINGERPRINT_KEY }} - run: poetry run pytest -vv tests/ + run: | + mkdir ./dist && touch ./dist/README.md + poetry run pytest -vv --cov=pybas_automation --cov-report=html tests/