Merge pull request #85 from JenspederM/test/deploy-test-fail #132
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
# .github/workflows/ci-cd.yml | |
on: | |
push: | |
branches: | |
- main | |
- master | |
jobs: | |
test: | |
name: Run tests | |
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
# Download the Databricks CLI. | |
# See https://github.com/databricks/setup-cli | |
- uses: databricks/setup-cli@main | |
- uses: eifinger/setup-rye@v3 | |
id: setup-rye | |
with: | |
version: "0.42.0" | |
- name: Pin python-version ${{ matrix.python-version }} | |
run: rye pin ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: rye sync --no-lock | |
- name: Lint code | |
run: rye lint | |
- name: Run tests | |
run: | | |
source .venv/bin/activate | |
rye test | |
env: | |
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }} | |
DATABRICKS_CLIENT_ID: ${{ secrets.DATABRICKS_CLIENT_ID }} | |
DATABRICKS_CLIENT_SECRET: ${{ secrets.DATABRICKS_CLIENT_SECRET }} | |
- name: Upload coverage reports to Codecov | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
pypi-publish: | |
name: Upload release to PyPI | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
strategy: | |
matrix: | |
python-version: ["3.9"] | |
environment: | |
name: pypi | |
url: https://pypi.org/p/kedro-databricks | |
permissions: | |
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
with: | |
token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" | |
fetch-depth: 0 | |
- name: Create bump and changelog | |
id: cz | |
uses: commitizen-tools/commitizen-action@master | |
with: | |
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
changelog_increment_filename: body.md | |
push: true | |
# Download the Databricks CLI. | |
# See https://github.com/databricks/setup-cli | |
- uses: databricks/setup-cli@main | |
- uses: eifinger/setup-rye@v3 | |
id: setup-rye | |
with: | |
version: "0.29.0" | |
enable-cache: true | |
cache-prefix: ${{ matrix.python-version }} | |
- name: Pin python-version ${{ matrix.python-version }} | |
if: steps.setup-rye.outputs.cache-hit != 'true' | |
run: rye pin ${{ matrix.python-version }} | |
- name: Install dependencies | |
if: steps.setup-rye.outputs.cache-hit != 'true' | |
run: | | |
rye sync --no-lock | |
- name: Build package | |
run: rye build | |
- name: Set Name and Version from pyproject.toml to output | |
id: project | |
run: | | |
name=$(grep "^name" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3 | tr "-" "_") | |
version=$(grep "^version" pyproject.toml -m 1 | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3) | |
echo "NAME=$name" >> $GITHUB_OUTPUT | |
echo "VERSION=$version" >> $GITHUB_OUTPUT | |
echo "Releasing $name version $version" | |
ls -laR dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- name: Upload release to GitHub | |
uses: softprops/action-gh-release@v1 | |
env: | |
PACKAGE_NAME: ${{ steps.project.outputs.NAME }} | |
VERSION: ${{ steps.project.outputs.VERSION }} | |
with: | |
tag_name: ${{ steps.cz.outputs.version }} | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
body_path: "body.md" | |
files: | | |
dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}-py3-none-any.whl | |
dist/${{ env.PACKAGE_NAME }}-${{ env.VERSION }}.tar.gz |