diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d820503..51970218 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,26 +3,6 @@ --- version: 2.1 -parameters: - python_version: - type: string - default: '3.11.7' - selenium_version: - type: string - default: '124.0' - se_node_max_sessions: - type: integer - default: 12 - se_node_session_timeout: - type: integer - default: 300 - screen_width: - type: integer - default: 1366 - screen_height: - type: integer - default: 768 - workflows: build-test-publish: jobs: @@ -46,7 +26,7 @@ workflows: jobs: pre-commit: docker: - - image: cimg/python:<> + - image: cimg/python:3.11.7 resource_class: medium steps: - checkout @@ -79,13 +59,13 @@ jobs: type: string default: "chrome" docker: - - image: cimg/python:<> - - image: selenium/standalone-<>:<> + - image: cimg/python:3.11.7 + - image: selenium/standalone-<>:124.0 environment: - SE_NODE_MAX_SESSIONS: <> - SE_NODE_SESSION_TIMEOUT: <> - SCREEN_WIDTH: <> - SCREEN_HEIGHT: <> + SE_NODE_MAX_SESSIONS: 12 + SE_NODE_SESSION_TIMEOUT: 300 + SCREEN_WIDTH: 1366 + SCREEN_HEIGHT: 768 resource_class: xlarge steps: - setup_remote_docker diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..30714982 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,123 @@ +name: build +# This is a beta version of migrating the CircleCI build to GH Actions +# TODO: Figure out and prevent firefox and edge tests getting auto-cancelled (out of memory?) +# TODO: Combine coverage reports in another job + +on: + workflow_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install depedencies + run: | + pip install poetry + poetry install --no-ansi + - uses: pre-commit/action@v3.0.1 + + unit: + needs: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install depedencies + run: | + pip install poetry + poetry install --no-ansi + - name: unit tests + run: | + poetry run coverage run -m pytest --junit-xml=output/unit-tests.xml + - name: package results + if: always() + run: | + mkdir -p output + mv .coverage.* output/ + tar cvfz output.tgz output + - name: save output + if: always() + uses: actions/upload-artifact@v4 + with: + name: unit-tests + path: output.tgz + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + check_name: "unit results" + files: | + output/unit-tests.xml + + cucu: + needs: unit + runs-on: ubuntu-latest + strategy: + matrix: + browser: ["chrome", "firefox", "edge"] + permissions: # to publish junit results - see https://github.com/EnricoMi/publish-unit-test-result-action?tab=readme-ov-file#permissions + contents: read + issues: read + checks: write + pull-requests: write + services: + webserver: + image: selenium/standalone-${{ matrix.browser }}:124.0 + ports: + - 4444:4444 + options: --shm-size=4gb + env: + SE_NODE_MAX_SESSIONS: 12 + SE_NODE_SESSION_TIMEOUT: 300 + SCREEN_WIDTH: 1366 + SCREEN_HEIGHT: 768 + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install depedencies + run: | + pip install poetry + poetry install --no-ansi + - name: wait_for_selenium + # retry connection every 2s x 60 which is a total of 2 minutes + run: curl --retry 60 --retry-delay 2 --retry-connrefused http://localhost:4444 + - name: UI tests + run: | + poetry run cucu run features --browser "${{ matrix.browser }}" --workers 1 --generate-report --report output/report --junit output/junit --selenium-remote-url http://localhost:4444 + env: + COVERAGE_PROCESS_START: pyproject.toml + SE_NODE_MAX_SESSIONS: 12 + SE_NODE_SESSION_TIMEOUT: 300 + SCREEN_WIDTH: 1366 + SCREEN_HEIGHT: 768 + DISPLAY: :99 # Needed for headless mode + SELENIUM_HOST: localhost + SELENIUM_PORT: 4444 + - name: package results + if: always() + run: | + mkdir -p output + mv .coverage.* output/ + tar cvfz output.tgz output + - name: save output + if: always() + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.browser }}-tests + path: output.tgz + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + check_name: "${{ matrix.browser }} results" + files: | + output/junit/**/*.xml diff --git a/.github/workflows/create_a_new_release.yml b/.github/workflows/create_a_new_release.yml index e5fdc99e..cda0d5cd 100644 --- a/.github/workflows/create_a_new_release.yml +++ b/.github/workflows/create_a_new_release.yml @@ -1,7 +1,8 @@ name: Create a New Release # The following job is run when a commit changes pyproject.toml file: # * Checks if the version of the project is the same of the latest release -# * If not, create a new release +# * If not, create a new release and then start the publishing +# * to test.pypi.org job on: push: @@ -35,3 +36,10 @@ jobs: -F prerelease=false \ -F generate_release_notes=true fi + - name: trigger publish-test workflow + run: | + curl -X POST \ + -H "Authorization: token ${{ github.token }}" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/${GITHUB_REPOSITORY}/dispatches \ + -d '{"event_type": "trigger_publish_test"}' diff --git a/.github/workflows/publish-production.yml b/.github/workflows/publish-production.yml new file mode 100644 index 00000000..c81b0537 --- /dev/null +++ b/.github/workflows/publish-production.yml @@ -0,0 +1,30 @@ +name: publish-production +# publish to test.pypi.org on merge to default branch + +on: + workflow_dispatch: + +jobs: + publish-production-main: + environment: cucu-publish-production # match name in www.PyPI.org OIDC + runs-on: ubuntu-latest + permissions: + id-token: write # Required for connection to pypi OIDC + steps: + - name: checkout main + uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install depedencies + run: | + pip install poetry + poetry install --no-ansi + - name: build package + run: | + poetry build + - name: publish to test.pypi.org + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/publish-test.yml b/.github/workflows/publish-test.yml new file mode 100644 index 00000000..51c4f762 --- /dev/null +++ b/.github/workflows/publish-test.yml @@ -0,0 +1,34 @@ +name: publish-test +# publish to test.pypi.org on merge to default branch + +on: + workflow_dispatch: + repository_dispatch: + types: [trigger_publish_test] + +jobs: + publish-test-main: + environment: cucu-publish-test # match name in test.PyPI.org OIDC + runs-on: ubuntu-latest + permissions: + id-token: write # Required for connection to pypi OIDC + steps: + - name: checkout main + uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: Install depedencies + run: | + pip install poetry + poetry install --no-ansi + - name: build package + run: | + poetry build + - name: publish to test.pypi.org + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/CHANGELOG.md b/CHANGELOG.md index e893446a..e2b6fcb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project closely adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.204.0 +- chore - add gh workflows for publishing +- chore - fix project metadata + ## 0.203.0 - chore - move repo GH org locations - chore - remove sonarqube diff --git a/pyproject.toml b/pyproject.toml index e2eb755f..a7e83a0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,13 @@ [tool.poetry] name = "cucu" -version = "0.203.0" -license = "MIT" +version = "0.204.0" description = "Easy BDD web testing" -authors = ["Domino Data Lab "] readme = "README.md" +license = "The Clear BSD License" +keywords = ["cucumber", "selenium", "behave"] homepage = "https://github.com/dominodatalab/cucu" repository = "https://github.com/dominodatalab/cucu" -keywords = ["cucumber", "selenium"] +authors = ["Domino Data Lab "] classifiers = [ "Development Status :: 4 - Beta", "Environment :: Console", @@ -18,7 +18,6 @@ classifiers = [ "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11",