Skip to content

Commit 8bd9783

Browse files
authored
chore(pipelines): PRs, merge main and upload on release (#1)
1 parent 4c66f11 commit 8bd9783

File tree

6 files changed

+376
-0
lines changed

6 files changed

+376
-0
lines changed

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/merge_main.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Merge Main
2+
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
10+
jobs:
11+
prepare:
12+
name: Calculate Version and Build Number
13+
runs-on: ubuntu-20.04
14+
15+
outputs:
16+
build_number: ${{ steps.build_number.outputs.value }}
17+
new_release: ${{ steps.semantic.outputs.new_release_published }}
18+
release: ${{ steps.semantic.outputs.new_release_version }}
19+
release_notes: ${{ steps.semantic.outputs.new_release_notes }}
20+
version: ${{ steps.version.outputs.value }}
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
token: ${{ secrets.ACCESS_TOKEN }}
26+
27+
- uses: cycjimmy/semantic-release-action@v2
28+
id: semantic
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
31+
with:
32+
dry_run: true
33+
semantic_version: 17.3.7
34+
35+
- name: Count number or releases for tag
36+
id: build_number
37+
run: echo "::set-output name=value::$(($(git tag | grep -c ${{ steps.semantic.outputs.new_release_version }}) + 1))"
38+
39+
- name: Compute version
40+
id: version
41+
run: echo "::set-output name=value::${{ steps.semantic.outputs.new_release_version }}.rc${{ steps.build_number.outputs.value }}"
42+
43+
44+
prerelease:
45+
if: needs.prepare.outputs.new_release == 'true'
46+
47+
name: Generates Prerelease
48+
runs-on: ubuntu-20.04
49+
50+
needs:
51+
- prepare
52+
53+
steps:
54+
- name: Create Pre Release
55+
uses: actions/create-release@v1
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
58+
with:
59+
tag_name: ${{ needs.prepare.outputs.version }}
60+
release_name: ${{ needs.prepare.outputs.version }}
61+
body: ${{ github.event.head_commit.message }}
62+
prerelease: true
63+
64+
65+
draft-release:
66+
if: needs.prepare.outputs.new_release == 'true'
67+
68+
name: Draft Release
69+
runs-on: ubuntu-20.04
70+
71+
needs:
72+
- prepare
73+
74+
steps:
75+
- name: Delete Previous drafts
76+
uses: hugo19941994/[email protected]
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
79+
80+
- name: Create Draft Release
81+
uses: actions/create-release@v1
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
84+
with:
85+
tag_name: ${{ needs.prepare.outputs.release }}
86+
release_name: ${{ needs.prepare.outputs.release }}
87+
body: ${{ needs.prepare.outputs.release_notes }}
88+
draft: true

.github/workflows/pull_request.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Pull Request
2+
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
9+
10+
env:
11+
PYTHON: python
12+
13+
14+
jobs:
15+
cancel_previous:
16+
name: 'Cancel Previous Runs'
17+
runs-on: ubuntu-20.04
18+
timeout-minutes: 3
19+
20+
steps:
21+
- uses: ydataai/[email protected]
22+
with:
23+
ignore_sha: true
24+
access_token: ${{ secrets.ACCESS_TOKEN }}
25+
26+
27+
validate:
28+
name: Validate
29+
runs-on: ubuntu-20.04
30+
31+
steps:
32+
- uses: actions/checkout@v3
33+
34+
- name: Setup Python 3.8
35+
uses: actions/setup-python@v4
36+
with:
37+
python-version: '3.8'
38+
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
43+
- name: Lint
44+
run: make lint PYTHON=$PYTHON

.github/workflows/release.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Releases
2+
3+
4+
5+
on:
6+
release:
7+
types:
8+
- prereleased
9+
- released
10+
11+
12+
13+
jobs:
14+
prepare:
15+
name: Prepare
16+
runs-on: ubuntu-20.04
17+
18+
outputs:
19+
version: ${{ steps.version.outputs.value }}
20+
21+
steps:
22+
- name: Version
23+
id: version
24+
run: echo ::set-output name=value::${GITHUB_REF#refs/*/}
25+
26+
27+
build-upload:
28+
name: Build and Upload
29+
runs-on: ubuntu-20.04
30+
31+
needs:
32+
- prepare
33+
34+
env:
35+
ROOT_DIR: src/core
36+
37+
steps:
38+
- uses: actions/checkout@v3
39+
40+
- name: Setup Python
41+
uses: actions/setup-python@v4
42+
with:
43+
python-version: '3.8'
44+
45+
- name: Install build dependencies
46+
run: python -m pip install --upgrade pip wheel
47+
48+
- name: Build
49+
run: |
50+
echo "${{ needs.prepare.outputs.version }}" > VERSION
51+
cd $ROOT_DIR && python setup.py sdist bdist_wheel
52+
53+
- name: Upload release assets
54+
uses: AButler/[email protected]
55+
with:
56+
files: '${{ env.ROOT_DIR }}/dist/*'
57+
repo-token: ${{ secrets.ACCESS_TOKEN }}
58+
release-tag: ${{ needs.prepare.outputs.version }}
59+
60+
- name: Upload package to pypi
61+
uses: pypa/[email protected]
62+
with:
63+
user: ${{ secrets.PRIVATE_PYPI_USERNAME }}
64+
password: ${{ secrets.PRIVATE_PYPI_PASSWORD }}
65+
repository_url: ${{ secrets.PRIVATE_PYPI_URL }}
66+
packages_dir: '${{ env.ROOT_DIR }}/dist/'
67+
68+
69+
# update-dockerfiles:
70+
# name: Create pull request to update dockerfiles
71+
# runs-on: ubuntu-20.04
72+
73+
# needs:
74+
# - prepare
75+
# - build-dask
76+
# - build-platform-common
77+
# - build-platform-dask
78+
# - build-platform-datasources
79+
# - build-platform-synthesizers
80+
81+
# env:
82+
# VERSION: ${{ needs.prepare.outputs.version }}
83+
84+
# steps:
85+
# - name: Checkout repo
86+
# uses: actions/checkout@v3
87+
# with:
88+
# repository: ydataai/dockerfiles
89+
# token: ${{ secrets.ACCESS_TOKEN }}
90+
91+
# - name: Update python base requirements file
92+
# env:
93+
# FILE: data-science/python_ydata_base/requirements-ydata.txt
94+
# run: |
95+
# sed -i -r 's|\ydata-dask==.*|ydata-dask==${{ env.VERSION }}|g' ${{ env.FILE }}
96+
# sed -i -r 's|\ydata-platform-common==.*|ydata-platform-common==${{ env.VERSION }}|g' ${{ env.FILE }}
97+
# sed -i -r 's|\ydata-platform-dask==.*|ydata-platform-dask==${{ env.VERSION }}|g' ${{ env.FILE }}
98+
# sed -i -r 's|\ydata-platform-datasources==.*|ydata-platform-datasources==${{ env.VERSION }}|g' ${{ env.FILE }}
99+
# sed -i -r 's|\ydata-platform-synthesizers==.*|ydata-platform-synthesizers==${{ env.VERSION }}|g' ${{ env.FILE }}
100+
101+
# - name: Create Pull Request
102+
# uses: peter-evans/create-pull-request@v3
103+
# with:
104+
# token: ${{ secrets.ACCESS_TOKEN }}
105+
# branch: chore/bump-platform-python-sdk
106+
# branch-suffix: random
107+
# delete-branch: true
108+
# commit-message: "chore(deps): bump platform-python-sdk to version ${{ env.VERSION }}"
109+
# committer: "Azory <[email protected]>"
110+
# title: "chore(deps): bump platform-python-sdk to version ${{ env.VERSION }}"
111+
# body: https://github.com/ydataai/platform-python-sdk/releases/tag/${{ env.VERSION }}
112+
# author: "Azory <[email protected]>"
113+
# reviewers: portellaa
114+
# team-reviewers: backend
115+
# labels: ci,platform-python-sdk
116+
117+
118+
# update-integration-tool:
119+
# name: Create pull request to update integration tool
120+
# runs-on: ubuntu-20.04
121+
122+
# needs:
123+
# - prepare
124+
# - build-dask
125+
# - build-platform-common
126+
# - build-platform-dask
127+
# - build-platform-datasources
128+
# - build-platform-synthesizers
129+
130+
# env:
131+
# VERSION: ${{ needs.prepare.outputs.version }}
132+
133+
# steps:
134+
# - name: Checkout repo
135+
# uses: actions/checkout@v3
136+
# with:
137+
# repository: ydataai/ydata-lib-platform-integration-tool
138+
# token: ${{ secrets.ACCESS_TOKEN }}
139+
140+
# - name: Update requirements file
141+
# env:
142+
# FILE: requirements.txt
143+
# run: |
144+
# sed -i -r 's|\ydata-dask==.*|ydata-dask==${{ env.VERSION }}|g' ${{ env.FILE }}
145+
# sed -i -r 's|\ydata-platform-common==.*|ydata-platform-common==${{ env.VERSION }}|g' ${{ env.FILE }}
146+
# sed -i -r 's|\ydata-platform-dask==.*|ydata-platform-dask==${{ env.VERSION }}|g' ${{ env.FILE }}
147+
# sed -i -r 's|\ydata-platform-datasources==.*|ydata-platform-datasources==${{ env.VERSION }}|g' ${{ env.FILE }}
148+
# sed -i -r 's|\ydata-platform-synthesizers==.*|ydata-platform-synthesizers==${{ env.VERSION }}|g' ${{ env.FILE }}
149+
150+
# - name: Create Pull Request
151+
# uses: peter-evans/create-pull-request@v4
152+
# with:
153+
# token: ${{ secrets.ACCESS_TOKEN }}
154+
# branch: chore/bump-platform-python-sdk
155+
# branch-suffix: random
156+
# delete-branch: true
157+
# committer: "Azory <[email protected]>"
158+
# commit-message: "chore(deps): bump platform-python-sdk to version ${{ env.VERSION }}"
159+
# title: "chore(deps): bump platform-python-sdk to version ${{ env.VERSION }}"
160+
# body: https://github.com/ydataai/platform-python-sdk/releases/tag/${{ env.VERSION }}
161+
# author: "Azory <[email protected]>"
162+
# reviewers: portellaa
163+
# team-reviewers: backend
164+
# labels: ci,platform-python-sdk

.releaserc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"tagFormat": "${version}",
3+
"plugins": [
4+
[
5+
"@semantic-release/commit-analyzer"
6+
],
7+
"@semantic-release/commit-analyzer",
8+
"@semantic-release/release-notes-generator",
9+
"@semantic-release/github"
10+
]
11+
}

Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
VENV := $(PWD)/.venv
2+
PYTHON := python
3+
PIP := $(PYTHON) -m pip
4+
5+
VERSION := $(file < VERSION)
6+
7+
.PHONY: help lint package clean
8+
9+
help: # The following lines will print the available commands when entering just 'make'
10+
ifeq ($(UNAME), Linux)
11+
@grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
12+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
13+
else
14+
@awk -F ':.*###' '$$0 ~ FS {printf "%15s%s\n", $$1 ":", $$2}' \
15+
$(MAKEFILE_LIST) | grep -v '@awk' | sort
16+
endif
17+
18+
venv3: ### Creates a virtual environment for this project
19+
test -d $(VENV) || python3.8 -m venv $(VENV)
20+
$(PIP) install --upgrade pip wheel setuptools twine
21+
22+
clean: clean-build clean-pyc ### Cleans artifacts
23+
24+
clean-build: ### Removes builds
25+
find . -type d -iname "build" ! -path "./.venv/*" -exec rm -rf {} +
26+
find . -type d -iname "dist" ! -path "./.venv/*" -exec rm -rf {} +
27+
find . -type d -iname "*.egg-info" ! -path "./.venv/*" -exec rm -rf {} +
28+
29+
clean-env: ### Removes environment directory
30+
rm -rf $(VENV)
31+
32+
clean-pyc: ### Removes python compiled bytecode files
33+
find . -iname "*.pyc" ! -path "./.venv/*" -delete
34+
find . -type d -iname "__pycache__" ! -path "./.venv/*" -exec rm -rf {} +
35+
36+
37+
define BUILD
38+
cd src/$1/ && rm -rf dist/ && $(PYTHON) setup.py sdist bdist_wheel
39+
endef
40+
41+
define INSTALL
42+
$(PIP) install src/$1/dist/ydata_$(subst -,_,$1)-$(VERSION)-py2.py3-none-any.whl
43+
endef
44+
45+
define UPLOAD
46+
cd src/$1/ && $(PYTHON) -m twine upload -r ydata dist/*
47+
endef
48+
49+
build: ### Build package
50+
$(call BUILD,core)
51+
52+
upload: ### Upload build package into pypi
53+
$(call UPLOAD,core)
54+
55+
lint: ### Run prospector
56+
$(PYTHON) -m prospector src/dask
57+
58+
define LINK_LOCAL
59+
$(PIP) install -e src/$1
60+
endef
61+
62+
link-local:
63+
$(call LINK_LOCAL,core)

0 commit comments

Comments
 (0)