diff --git a/.gitea/workflows/build_pypackage.yml b/.gitea/workflows/build_pypackage.yml new file mode 100644 index 0000000..fcd0d77 --- /dev/null +++ b/.gitea/workflows/build_pypackage.yml @@ -0,0 +1,38 @@ +name: build pypackage + +on: + workflow_call: + inputs: + repository: + required: true + type: string + description: "package repository" + + secrets: + username: + required: true + description: "repository username" + token: + required: true + description: "repository token/password" + +jobs: + build-pypackage: + runs-on: python311 + env: + HATCH_INDEX_REPO: ${{ inputs.repository }} + HATCH_INDEX_USER: ${{ secrets.username }} + HATCH_INDEX_AUTH: ${{ secrets.token }} + steps: + - name: checkout code + uses: actions/checkout@v3 + + - name: install hatch + run: pip install -U hatch hatchling + + - name: build package + run: hatch build --clean + + - name: publish package + if: gitea.event_name != 'pull_request' + run: hatch publish --yes --no-prompt diff --git a/.gitea/workflows/check_python.yml b/.gitea/workflows/check_python.yml new file mode 100644 index 0000000..a8f3938 --- /dev/null +++ b/.gitea/workflows/check_python.yml @@ -0,0 +1,43 @@ +name: check/lint python code + +on: + workflow_call: + inputs: + src-dir: + required: false + type: string + description: "source directory" + default: "." + run-tests: + required: false + type: boolean + description: "run tests" + default: false + tests-dir: + required: false + type: string + description: "tests directory" + default: "tests" + +jobs: + check-python: + runs-on: python311 + steps: + - name: checkout code + uses: actions/checkout@v3 + + - name: install requirements + run: pip install -U ruff mypy pytest + + - name: test mypy + run: mypy --non-interactive --install-types ${{ inputs.src-dir }} + + - name: test ruff check + run: ruff check --diff ${{ inputs.src-dir }} + + - name: test ruff format + run: ruff format --check --diff ${{ inputs.src-dir }} + + - name: run tests + if: ${{ inputs.run-tests == true }} + run: pytest --exitfirst --verbose ${{ inputs.tests-dir }} diff --git a/.gitea/workflows/check_python_hatch.yml b/.gitea/workflows/check_python_hatch.yml new file mode 100644 index 0000000..1e8b929 --- /dev/null +++ b/.gitea/workflows/check_python_hatch.yml @@ -0,0 +1,30 @@ +name: check/lint python code with hatch + +on: + workflow_call: + inputs: + run-tests: + required: false + type: boolean + description: "run tests" + default: false + +jobs: + check-python-hatch: + runs-on: python311 + steps: + - name: checkout code + uses: actions/checkout@v3 + + - name: install hatch + run: pip install -U hatch + + - name: test codestyle + run: hatch run lint:fmt + + - name: test typing + run: hatch run lint:typing + + - name: run tests + if: ${{ inputs.run-tests == true }} + run: hatch run default:test diff --git a/.gitea/workflows/release_pypackage.yml b/.gitea/workflows/release_pypackage.yml new file mode 100644 index 0000000..acb24bf --- /dev/null +++ b/.gitea/workflows/release_pypackage.yml @@ -0,0 +1,56 @@ +name: build and release pypackage + +on: + workflow_call: + inputs: + repository: + required: true + type: string + description: "package repository" + release-body: + required: false + type: string + description: "body of the release" + + secrets: + username: + required: true + description: "repository username" + token: + required: true + description: "repository token/password" + +jobs: + release-pypackage: + runs-on: python311 + env: + HATCH_INDEX_REPO: ${{ inputs.repository }} + HATCH_INDEX_USER: ${{ secrets.username }} + HATCH_INDEX_AUTH: ${{ secrets.token }} + steps: + - name: checkout code + uses: actions/checkout@v3 + + - name: setup go + uses: actions/setup-go@v4 + with: + go-version: '>=1.20' + + - name: install hatch + run: pip install -U hatch hatchling + + - name: build package + run: hatch build --clean + + - name: publish package + if: gitea.event_name != 'pull_request' + run: hatch publish --yes --no-prompt + + - name: create gitea release + uses: https://gitea.com/actions/release-action@main + if: gitea.event_name != 'pull_request' + with: + title: ${{ gitea.ref_name }} + body: ${{ inputs.release-body }} + files: |- + dist/** diff --git a/.gitea/workflows/sonarqube_python.yml b/.gitea/workflows/sonarqube_python.yml new file mode 100644 index 0000000..224f9f4 --- /dev/null +++ b/.gitea/workflows/sonarqube_python.yml @@ -0,0 +1,50 @@ +name: upload code to sonarqube + +on: + workflow_call: + inputs: + coverage: + required: false + type: boolean + description: "generate coverage" + default: false + tests-dir: + required: false + type: string + description: "tests directory" + default: "tests" + + secrets: + sonar-host: + required: true + description: "sonarqube instance url" + sonar-token: + required: true + description: "sonarqube auth token" + +jobs: + scan-code: + runs-on: python311 + steps: + - name: checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: install requirements + if: ${{ inputs.coverage == true }} + run: pip install -U pytest coverage + + - name: get coverage + if: ${{ inputs.coverage == true }} + run: | + coverage erase + coverage run -m pytest --exitfirst --verbose ${{ inputs.tests-dir }} + coverage report + coverage xml + + - name: run sonar-scanner + uses: sonarsource/sonarqube-scan-action@v2.0.1 + env: + SONAR_HOST_URL: ${{ secrets.sonar-host }} + SONAR_TOKEN: ${{ secrets.sonar-token }} diff --git a/.gitea/workflows/update_changelog.yml b/.gitea/workflows/update_changelog.yml new file mode 100644 index 0000000..a003919 --- /dev/null +++ b/.gitea/workflows/update_changelog.yml @@ -0,0 +1,30 @@ +name: generate and update changelog + +on: + workflow_call: + +jobs: + update-changelog: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + ref: master + + - name: install auto-changelog + run: npm install -g auto-changelog + + - name: generate changelog + run: >- + auto-changelog -t keepachangelog --unreleased + --ignore-commit-pattern '(B|b)ump version|update changelog' + + - name: commit changes + uses: EndBug/add-and-commit@v9 + if: gitea.event_name != 'pull_request' + with: + message: "[bot] update changelog" + author_name: actions-bot + author_email: actions@bots.44net.ch