Skip to content

Commit f6c2940

Browse files
authored
Setting up github actions for SQLAlachemy v1 (#8)
* Modified example.py * workflow dispatch * Added github workflows * Updated publishing to test pypi * Check * Check * Check * Check * Check * Check * Check * Check * Fixed the github actions not working issue * Ignore imports in mypy * Minor fix * Minor fix
1 parent c4cb345 commit f6c2940

File tree

6 files changed

+155
-0
lines changed

6 files changed

+155
-0
lines changed

.github/workflows/code-quality-checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
branches:
88
- v1/main
9+
workflow_dispatch:
910
jobs:
1011
check-linting:
1112
runs-on: ubuntu-latest

.github/workflows/dco-check.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: DCO Check
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
check:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check for DCO
10+
id: dco-check
11+
uses: tisonkun/[email protected]
12+
- name: Comment about DCO status
13+
uses: actions/github-script@v6
14+
if: ${{ failure() }}
15+
with:
16+
script: |
17+
github.rest.issues.createComment({
18+
issue_number: context.issue.number,
19+
owner: context.repo.owner,
20+
repo: context.repo.repo,
21+
body: `Thanks for your contribution! To satisfy the DCO policy in our \
22+
[contributing guide](https://github.com/databricks/databricks-sqlalchemy/blob/main/CONTRIBUTING.md) \
23+
every commit message must include a sign-off message. One or more of your commits is missing this message. \
24+
You can reword previous commit messages with an interactive rebase (\`git rebase -i main\`).`
25+
})

.github/workflows/publish-test.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish to PyPI [Test]
2+
on: [push]
3+
jobs:
4+
test-pypi:
5+
name: Create patch version number and push to test-pypi
6+
runs-on: ubuntu-latest
7+
steps:
8+
#----------------------------------------------
9+
# check-out repo and set-up python
10+
#----------------------------------------------
11+
- name: Check out repository
12+
uses: actions/checkout@v2
13+
- name: Set up python
14+
id: setup-python
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
18+
#----------------------------------------------
19+
# ----- install & configure poetry -----
20+
#----------------------------------------------
21+
- name: Install Poetry
22+
uses: snok/install-poetry@v1
23+
with:
24+
virtualenvs-create: true
25+
virtualenvs-in-project: true
26+
installer-parallel: true
27+
#----------------------------------------------
28+
# load cached venv if cache exists
29+
#----------------------------------------------
30+
- name: Load cached venv
31+
id: cached-poetry-dependencies
32+
uses: actions/cache@v2
33+
with:
34+
path: .venv
35+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
36+
#----------------------------------------------
37+
# install dependencies if cache does not exist
38+
#----------------------------------------------
39+
- name: Install dependencies
40+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
41+
run: poetry install --no-interaction --no-root
42+
#----------------------------------------------
43+
# Get the current version and increment it (test-pypi requires a unique version number)
44+
#----------------------------------------------
45+
- name: Get next version
46+
uses: reecetech/[email protected]
47+
id: version
48+
with:
49+
scheme: semver
50+
increment: patch
51+
#----------------------------------------------
52+
# Tell poetry to update the version number
53+
#----------------------------------------------
54+
- name: Update pyproject.toml
55+
run: poetry version ${{ steps.version.outputs.major-version }}.${{ steps.version.outputs.minor-version }}.dev$(date +%s)
56+
57+
- name: Build and publish to pypi
58+
uses: JRubics/[email protected]
59+
with:
60+
pypi_token: ${{ secrets.SQLALCHEMY_TEST_PYPI_TOKEN }}
61+
repository_name: "testpypi"
62+
repository_url: "https://test.pypi.org/legacy/"

.github/workflows/publish.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish to PyPI [Production]
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
publish:
7+
name: Publish
8+
runs-on: ubuntu-latest
9+
if: github.ref == 'refs/heads/v1/main'
10+
steps:
11+
#----------------------------------------------
12+
# check-out repo and set-up python
13+
#----------------------------------------------
14+
- name: Check out repository
15+
uses: actions/checkout@v2
16+
- name: Set up python
17+
id: setup-python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: 3.9
21+
#----------------------------------------------
22+
# ----- install & configure poetry -----
23+
#----------------------------------------------
24+
- name: Install Poetry
25+
uses: snok/install-poetry@v1
26+
with:
27+
virtualenvs-create: true
28+
virtualenvs-in-project: true
29+
installer-parallel: true
30+
#----------------------------------------------
31+
# load cached venv if cache exists
32+
#----------------------------------------------
33+
- name: Load cached venv
34+
id: cached-poetry-dependencies
35+
uses: actions/cache@v2
36+
with:
37+
path: .venv
38+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ github.event.repository.name }}-${{ hashFiles('**/poetry.lock') }}
39+
#----------------------------------------------
40+
# install dependencies if cache does not exist
41+
#----------------------------------------------
42+
- name: Install dependencies
43+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
44+
run: poetry install --no-interaction --no-root
45+
#------------------------------------------------------------------------------------------------
46+
# Here we use version-increment to fetch the latest tagged version (we won't increment it though)
47+
#------------------------------------------------------------------------------------------------
48+
- name: Get next version
49+
uses: reecetech/[email protected]
50+
id: version
51+
with:
52+
scheme: semver
53+
increment: patch
54+
#-----------------------------------------------------------------------------
55+
# Tell poetry to use the `current-version` that was found by the previous step
56+
#-----------------------------------------------------------------------------
57+
- name: Update pyproject.toml
58+
run: poetry version ${{ steps.version.outputs.current-version }}
59+
#----------------------------------------------
60+
# Attempt push to test-pypi
61+
#----------------------------------------------
62+
- name: Build and publish to pypi
63+
uses: JRubics/[email protected]
64+
with:
65+
pypi_token: ${{ secrets.SQLALCHEMY_PROD_PYPI_TOKEN }}

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ build-backend = "poetry.core.masonry.api"
3535
[tool.black]
3636
exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|thrift_api)/'
3737

38+
[tool.mypy]
39+
ignore_missing_imports = true

src/databricks/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)