Skip to content

Commit 1040694

Browse files
authored
ci: Enhance release procedure (#152)
- Change pipenv with Poetry for better dependency resolution and publication. - Modify CI workflows with Matrix strategy to test it in Python 3.6, 3.7 and 3.8. - Modify CD workflow to add git-chglog for better release message generation. * ci: Enhance release procedure * fix: Make the scope work with tatsu 4.4.0 * ci: Break tests into scheduled for master and fail-fast for PRs * ci: Break tests into integration and integration-agent kind * release: Remove unrequired pipenv and setuptools files
1 parent 2b4ff08 commit 1040694

26 files changed

+635
-673
lines changed

.github/git-chglog/CHANGELOG.tpl.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{{ range .Versions }}
2+
{{ range .CommitGroups -}}
3+
### {{ .Title }}
4+
5+
{{ range .Commits -}}
6+
* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
7+
{{ end }}
8+
{{ end -}}
9+
10+
{{- if .RevertCommits -}}
11+
### Reverts
12+
13+
{{ range .RevertCommits -}}
14+
* {{ .Revert.Header }}
15+
{{ end }}
16+
{{ end -}}
17+
18+
{{- if .NoteGroups -}}
19+
{{ range .NoteGroups -}}
20+
### {{ .Title }}
21+
22+
{{ range .Notes }}
23+
{{ .Body }}
24+
{{ end }}
25+
{{ end -}}
26+
{{ end -}}
27+
{{ end -}}

.github/git-chglog/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/sysdiglabs/sysdig-sdk-python
6+
options:
7+
commits:
8+
# filters:
9+
# Type:
10+
# - feat
11+
# - fix
12+
# - perf
13+
# - refactor
14+
commit_groups:
15+
title_maps:
16+
feat: Features
17+
fix: Bug Fixes
18+
perf: Performance Improvements
19+
refactor: Code Refactoring
20+
ci: Continuous Integration
21+
docs: Documentation
22+
chore: Small Modifications
23+
build: Compilation & Dependencies
24+
header:
25+
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
26+
pattern_maps:
27+
- Type
28+
- Scope
29+
- Subject
30+
notes:
31+
keywords:
32+
- BREAKING CHANGE
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI - Master - Scheduled
2+
3+
on:
4+
schedule:
5+
- cron: "0 1 * * *" # 1 AM everyday https://crontab.guru/#0_1_*_*_*
6+
7+
jobs:
8+
scheduled-test:
9+
strategy:
10+
max-parallel: 1
11+
fail-fast: false
12+
matrix:
13+
python_version:
14+
# https://python-release-cycle.glitch.me/
15+
- "3.6"
16+
- "3.7"
17+
- "3.8"
18+
- "3.9"
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
23+
- uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python_version }}
26+
27+
- name: Install Poetry
28+
run: python -m pip install poetry poetry-dynamic-versioning
29+
30+
- uses: actions/cache@v2
31+
name: Cache Poetry dependencies
32+
with:
33+
path: |
34+
~/.cache
35+
~/.local/share/virtualenvs/
36+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
37+
restore-keys: |
38+
${{ runner.os }}-poetry-
39+
40+
- name: Get dependencies
41+
run: poetry install
42+
43+
- name: Lint
44+
continue-on-error: true
45+
run: |
46+
# stop the build if there are Python syntax errors or undefined names
47+
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
48+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
49+
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
50+
51+
- name: Travis Test - Start agent
52+
id: start_agent
53+
env:
54+
PYTHON_SDC_TEST_ACCESS_KEY: ${{ secrets.STAGING_AGENT_KEY }}
55+
run: |
56+
sudo apt-get install linux-headers-$(uname -r) dkms gcc-multilib g++-multilib
57+
./test/start_agent.sh
58+
59+
- name: Travis Test - Install dependencies
60+
run: |
61+
poetry build
62+
python -m pip install $(find dist -iname "*.whl" | head -1)
63+
64+
- name: Travis Test - Secure APIs
65+
env:
66+
PYTHON_SDC_TEST_API_TOKEN: ${{ secrets.STAGING_SECURE_API_TOKEN }}
67+
run: ./test/test_secure_apis.sh
68+
69+
- name: Test in staging
70+
env:
71+
SDC_MONITOR_TOKEN: ${{ secrets.STAGING_MONITOR_API_TOKEN }}
72+
SDC_SECURE_TOKEN: ${{ secrets.STAGING_SECURE_API_TOKEN }}
73+
SDC_MONITOR_URL: "https://app-staging.sysdigcloud.com"
74+
SDC_SECURE_URL: "https://secure-staging.sysdig.com"
75+
run: poetry run mamba -f documentation
76+
77+
- name: Travis Test - Stop agent
78+
run: ./test/stop_agent.sh
79+
if: steps.start_agent.outcome == 'success'

.github/workflows/ci-pull-request.yml

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,53 @@ on:
77

88
jobs:
99
test:
10+
strategy:
11+
max-parallel: 1
12+
fail-fast: true
13+
matrix:
14+
python_version:
15+
# https://python-release-cycle.glitch.me/
16+
- "3.6"
17+
- "3.7"
18+
- "3.8"
19+
- "3.9"
1020
runs-on: ubuntu-latest
1121
steps:
1222
- uses: actions/checkout@v2
1323

1424
- uses: actions/setup-python@v2
1525
with:
16-
python-version: '3.8'
26+
python-version: ${{ matrix.python_version }}
1727

18-
- name: Install pipenv
19-
run: python -m pip install pipenv
28+
- name: Install Poetry
29+
run: python -m pip install poetry poetry-dynamic-versioning
2030

2131
- uses: actions/cache@v2
22-
name: Cache Pipenv dependencies
32+
name: Cache Poetry dependencies
2333
with:
2434
path: |
2535
~/.cache
2636
~/.local/share/virtualenvs/
27-
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
37+
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
2838
restore-keys: |
29-
${{ runner.os }}-pipenv-
39+
${{ runner.os }}-poetry-
3040
3141
- name: Get dependencies
32-
run: pipenv install -d
42+
run: poetry install
3343

3444
- name: Lint
3545
continue-on-error: true
3646
run: |
3747
# stop the build if there are Python syntax errors or undefined names
38-
pipenv run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
48+
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3949
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
40-
pipenv run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
50+
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
4151
42-
- name: Travis Test - Start agent
43-
id: start_agent
44-
env:
45-
PYTHON_SDC_TEST_ACCESS_KEY: ${{ secrets.STAGING_AGENT_KEY }}
46-
run: |
47-
sudo apt-get install linux-headers-$(uname -r) dkms gcc-multilib g++-multilib
48-
./test/start_agent.sh
49-
50-
- name: Travis Test - Install dependencies
51-
run: pip install .
52-
53-
- name: Travis Test - Secure APIs
54-
env:
55-
PYTHON_SDC_TEST_API_TOKEN: ${{ secrets.STAGING_SECURE_API_TOKEN }}
56-
run: ./test/test_secure_apis.sh
5752
5853
- name: Test in staging
5954
env:
6055
SDC_MONITOR_TOKEN: ${{ secrets.STAGING_MONITOR_API_TOKEN }}
6156
SDC_SECURE_TOKEN: ${{ secrets.STAGING_SECURE_API_TOKEN }}
6257
SDC_MONITOR_URL: "https://app-staging.sysdigcloud.com"
6358
SDC_SECURE_URL: "https://secure-staging.sysdig.com"
64-
run: |
65-
pipenv run mamba -f documentation
66-
67-
- name: Travis Test - Stop agent
68-
run: ./test/stop_agent.sh
69-
if: steps.start_agent.outcome == 'success'
59+
run: poetry run mamba -f documentation -t integration

.github/workflows/release.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@ jobs:
1212
upload_url: ${{ steps.create_release.outputs.upload_url }}
1313

1414
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: '^1.15'
23+
24+
- name: Setup go-chglog
25+
run: go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
26+
27+
- name: Generate changelog
28+
run: git-chglog -c .github/git-chglog/config.yml -o RELEASE_CHANGELOG.md $(git describe --tags $(git rev-list --tags --max-count=1))
29+
1530
- name: Create Release
1631
id: create_release
1732
uses: actions/create-release@v1
@@ -22,14 +37,7 @@ jobs:
2237
release_name: ${{ github.ref }}
2338
draft: true
2439
prerelease: false
25-
body: |
26-
This is the ${{ github.ref }} release of the sysdig-sdk-python (sdcclient), the Python client for Sysdig Platform
27-
28-
### Major Changes
29-
30-
### Minor Changes
31-
32-
### Bug fixes
40+
body_path: RELEASE_CHANGELOG.md
3341

3442
pypi:
3543
runs-on: ubuntu-latest
@@ -45,12 +53,7 @@ jobs:
4553
- name: Install dependencies
4654
run: |
4755
python -m pip install --upgrade pip
48-
pip install setuptools wheel twine
56+
pip install poetry poetry-dynamic-versioning
4957
5058
- name: Build and publish
51-
env:
52-
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
53-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
54-
run: |
55-
python setup.py sdist bdist_wheel
56-
twine upload dist/*
59+
run: poetry publish --build -u ${{ secrets.PYPI_USER }} -p ${{ secrets.PYPI_PASSWORD }}

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
.PHONY: test
44
test:
5-
pipenv run mamba -f documentation
5+
poetry run mamba -f documentation
66

77
.coverage:
8-
pipenv run coverage run $(shell pipenv run which mamba) -f documentation || true
8+
poetry run coverage run $(shell poetry run which mamba) -f documentation || true
99

1010
cover: .coverage
11-
pipenv run coverage report --include 'sdcclient/*'
11+
poetry run coverage report --include 'sdcclient/*'
1212

1313
.PHONY: cover-html
1414
cover-html: .coverage
15-
pipenv run coverage html -d coverage --include 'sdcclient/*'
15+
poetry run coverage html -d coverage --include 'sdcclient/*'
1616

Pipfile

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)