build #2354
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
create: | |
tags: | |
- v* | |
push: | |
branches: | |
- main | |
pull_request: | |
schedule: | |
# At 00:00 on Monday | |
- cron: '0 0 * * 1' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
# renovate: datasource=pypi depName=pdm versioning=pep440 | |
PDM_VERSION: 2.15.4 | |
# renovate: datasource=pypi depName=pre-commit versioning=pep440 | |
PRE_COMMIT_VERSION: 3.5.0 | |
jobs: | |
test: | |
name: test - python ${{ matrix.python-version }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- '3.8' | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
version: ${{ env.PDM_VERSION }} | |
cache: true | |
- name: Set up Mattermost instance | |
run: tests/scripts/setup-mattermost.sh | |
- name: Install dependencies | |
run: pdm install --frozen-lockfile | |
- name: Run tests | |
run: >- | |
pdm run pytest | |
--color=yes | |
--cov | |
--cov-report="xml:coverage-reports/coverage-${PYTHON_VERSION}.xml" | |
env: | |
PYTHON_VERSION: ${{ matrix.python-version }} | |
- name: Archive coverage report | |
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | |
with: | |
name: coverage-reports-${{ matrix.python-version }} | |
path: coverage-reports/coverage-${{ matrix.python-version }}.xml | |
lint: | |
name: lint - python ${{ matrix.python-version }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- '3.8' | |
- '3.9' | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
timeout-minutes: 15 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up pre-commit | |
run: pipx install --python=python "pre-commit==${PRE_COMMIT_VERSION}" | |
- name: Set up pre-commit cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit-${{ env.pythonLocation }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Run pre-commit | |
run: pre-commit run --show-diff-on-failure --color=always --all-files | |
sonar-scan: | |
name: sonar scan | |
needs: [test] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: read | |
timeout-minutes: 15 | |
steps: | |
# Full checkout for SonarQube | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
fetch-depth: 0 | |
- name: Download coverage reports | |
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 | |
with: | |
pattern: coverage-reports-* | |
path: coverage-reports/ | |
merge-multiple: true | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 # v2.3.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
publish: | |
name: publish | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
needs: [lint, test, sonar-scan] | |
runs-on: ubuntu-latest | |
environment: | |
name: PyPI | |
url: https://pypi.org/project/mmemoji | |
permissions: | |
contents: read | |
id-token: write | |
timeout-minutes: 15 | |
env: | |
PYTHON_VERSION: '3.12' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@568ddd69406b30de1774ec0044b73ae06e716aa4 # v4 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
version: ${{ env.PDM_VERSION }} | |
cache: true | |
- name: Build | |
run: pdm build | |
- name: Publish to PyPi | |
run: pdm publish |