diff --git a/.github/actions/setup-poetry/action.yml b/.github/actions/setup-poetry/action.yml new file mode 100644 index 0000000..33898ab --- /dev/null +++ b/.github/actions/setup-poetry/action.yml @@ -0,0 +1,20 @@ +name: Setup Poetry +description: Cross-platform Poetry installation + +runs: + using: "composite" + steps: + - name: Install Poetry (Linux/macOS) + if: runner.os != 'Windows' + shell: bash + run: | + curl -sSL https://install.python-poetry.org | python3 - + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Install Poetry (Windows) + if: runner.os == 'Windows' + shell: pwsh + run: | + (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - + echo "$env:APPDATA\Python\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Append + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ece6805 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,123 @@ +name: Python CI + +on: + pull_request: + branches: [ master ] + push: + branches: [ master ] + release: + types: [ released ] + +jobs: + lint: + runs-on: ubuntu-latest + name: Lint + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install Poetry + uses: ./.github/actions/setup-poetry + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cache/pypoetry + ~/.cache/pip + key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }} + restore-keys: | + ${{ runner.os }}-poetry- + + - name: Install dependencies + run: poetry install + + - name: Install tox + run: python -m pip install --upgrade tox + + - name: Run lint + run: tox -e lint + + test: + name: Python ${{ matrix.python-version }} (${{ matrix.platform }}) + needs: lint + runs-on: ${{ matrix.platform }} + + strategy: + fail-fast: false + matrix: + include: + - python-version: "3.9" + platform: ubuntu-latest + toxenv: py39 + - python-version: "3.10" + platform: ubuntu-latest + toxenv: py310 + - python-version: "3.11" + platform: ubuntu-latest + toxenv: py311 + - python-version: "3.12" + platform: ubuntu-latest + toxenv: py312 + - python-version: "3.13" + platform: ubuntu-latest + toxenv: py313 + - python-version: "3.12" + platform: macos-latest + toxenv: py312 + - python-version: "3.12" + platform: windows-latest + toxenv: py312 + + steps: + - uses: actions/checkout@v4 + + - name: Install Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Poetry + uses: ./.github/actions/setup-poetry + + - name: Install dependencies + run: poetry install + + - name: Install tox + run: python -m pip install --upgrade tox + + - name: Run tests + run: tox -e ${{ matrix.toxenv }} + + - name: Run Codecov + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + run: tox -e codecov + + release: + runs-on: ubuntu-latest + needs: test + if: github.ref == 'refs/heads/master' && github.event_name == 'push' + + steps: + - uses: actions/checkout@v4 + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install Poetry + uses: ./.github/actions/setup-poetry + + - name: Install dependencies + run: poetry install + + - name: Run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: poetry run semantic-release publish diff --git a/.taskcluster.yml b/.taskcluster.yml deleted file mode 100644 index 4ea07ff..0000000 --- a/.taskcluster.yml +++ /dev/null @@ -1,102 +0,0 @@ -version: 1 -policy: - pullRequests: collaborators -tasks: - $let: - - project_name: - bugmon - - matrix: - language: python - secrets: - - type: env - secret: project/fuzzing/codecov-bugmon - name: CODECOV_TOKEN - key: token - script: - - bash - - '-xec' - - tox; tox -e codecov - jobs: - include: - - name: tests python 3.9 - version: "3.9" - env: - TOXENV: py39 - - name: tests python 3.10 - version: "3.10" - env: - TOXENV: py310 - - name: tests python 3.11 - version: "3.11" - env: - TOXENV: py311 - - name: tests python 3.12 - version: "3.12" - env: - TOXENV: py312 - - name: lint - version: "3.10" - env: - TOXENV: lint - script: - - tox - - name: semantic-release - version: "3.10" - script: - - bash - - '-xec' - - >- - git config --global user.email "bugmon@mozilla.com"; - git config --global user.name "semantic-release"; - git fetch origin master --tags; - git checkout -b master; - tox -e release - when: - branch: master - all_passed: true - secrets: - - type: key - secret: project/fuzzing/deploy-bugmon - key: key - - in: - $if: > - (tasks_for == "github-push") - || (tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "synchronize"]) - || (tasks_for == "github-release" && event["action"] in ["published"]) - then: - - created: { $fromNow: '' } - deadline: { $fromNow: '1 hour' } - provisionerId: proj-fuzzing - workerType: ci - payload: - features: - taskclusterProxy: true - maxRunTime: 3600 - image: - type: indexed-image - path: public/orion-decision.tar.zst - namespace: project.fuzzing.orion.orion-decision.master - env: - PROJECT_NAME: ${project_name} - CI_MATRIX: { $json: { $eval: matrix } } - GITHUB_EVENT: { $json: { $eval: event } } - GITHUB_ACTION: ${tasks_for} - TASKCLUSTER_NOW: ${now} - command: - - ci-decision - - -v - scopes: - - queue:create-task:highest:proj-fuzzing/ci - - queue:create-task:highest:proj-fuzzing/ci-* - - queue:scheduler-id:taskcluster-github - - secrets:get:project/fuzzing/codecov-bugmon - - secrets:get:project/fuzzing/deploy-bugmon - metadata: - name: ${project_name} ci decision - description: schedule ci tasks for ${project_name} - owner: '${event.sender.login}@users.noreply.github.com' - source: https://github.com/MozillaSecurity/bugzilla - else: [ ] diff --git a/pyproject.toml b/pyproject.toml index 440c18d..e5faca6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,9 +118,6 @@ disable = [ [tool.pytest.ini_options] log_level = "DEBUG" -[tool.semantic_relase.publish] -upload_to_vcs_release = false - [tool.semantic_release] build_command = "poetry build" commit_message = "chore(release): {version} [skip ci]" diff --git a/tox.ini b/tox.ini index 8fa209c..76c142b 100644 --- a/tox.ini +++ b/tox.ini @@ -10,14 +10,13 @@ commands = poetry run pytest --cache-clear --cov="{toxinidir}" --cov-config="{to skip_install = true [testenv:codecov] -allowlist_externals = - codecov - poetry commands = - poetry run coverage xml --ignore-errors - codecov -deps = coverage[toml] -passenv = CODECOV_TOKEN + codecov upload-process +deps = + codecov-cli + coverage[toml] +passenv = + CODECOV_TOKEN skip_install = true [testenv:lint] @@ -28,7 +27,7 @@ skip_install = true [testenv:release] commands = - semantic-release -v version --no-changelog --no-vcs-release + semantic-release -v version --no-changelog semantic-release -v publish passenv = HOME skip_install = true