Skip to content

Commit 78a5bee

Browse files
committed
👷 Defined CI flow in GitHub actions
1 parent 428757d commit 78a5bee

File tree

9 files changed

+793
-53
lines changed

9 files changed

+793
-53
lines changed

.github/workflows/ci.yml

Lines changed: 194 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,67 +14,211 @@ env:
1414
python_cache_ubuntu_path: |
1515
~/.cache/pip
1616
jobs:
17+
# Check that a news file has been added to this branch when a PR is created
18+
assert-news:
19+
name: Assert news files (See CONTRIBUTING.md)
20+
runs-on: ubuntu-latest
21+
steps:
22+
# Checkout with full history for to allow compare with base branch
23+
- uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
- uses: actions/setup-python@v2
27+
- uses: FranzDiebold/github-env-vars-action@v2
28+
- name: Load Python Dependencies from cache
29+
uses: actions/cache@v2
30+
with:
31+
path: ${{ env.python_cache_ubuntu_path }}
32+
key: linux-pip-3-continuous-delivery-scripts
33+
- name: Install CI/CD tools
34+
run: |
35+
python -m pip install --upgrade pip
36+
python -m pip install continuous-delivery-scripts
37+
python -m pip list
38+
- name: Assert news
39+
run: cd-assert-news -b ${CI_ACTION_REF_NAME}
40+
env:
41+
GIT_TOKEN: ${{ secrets.GIT_SECRET }}
42+
- name: Report failure if needed
43+
if: ${{ failure() }}
44+
run: |
45+
echo "::error:: News file missing (See CONTRIBUTING.md guide for details)."
46+
47+
48+
generate-docs:
49+
name: Build Documentation
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v2
53+
- uses: actions/setup-python@v2
54+
- name: Determine dependencies
55+
# Note
56+
# The below code generates a pip requirements file from the pipenv development requirements (also obtaining the
57+
# normal dependencies from setup.py).
58+
# This code also forces the system to install latest tools as the ones present on the CI system may be too old
59+
# for the process to go through properly.
60+
run: |
61+
python -m pip install --upgrade pip wheel setuptools
62+
python -m pip install flake8 pipenv pytest
63+
python -m pipenv lock --dev -r --pre > dev-requirements.txt
64+
- uses: FranzDiebold/github-env-vars-action@v2
65+
- name: Load Python Dependencies from cache
66+
uses: actions/cache@v2
67+
with:
68+
path: ${{ env.python_cache_ubuntu_path }}
69+
key: linux-pip-3-continuous-delivery-scripts
70+
- name: Install dependencies
71+
# Note
72+
# As a virtual machine is already being used, pipenv
73+
# is superfluous and eliminating pipenv in CI reduces overhead and reduce complexity, while retaining a single
74+
# location for development dependencies.
75+
run: |
76+
python -m pip install -r dev-requirements.txt
77+
python -m pip list
78+
- name: Generate Documentation
79+
run: |
80+
cd-generate-docs --output_dir $(cd-get-config --key DOCUMENTATION_PRODUCTION_OUTPUT_PATH)
81+
- name: Add copyright/licence notice.
82+
run: |
83+
cd-license-files
84+
85+
tpip:
86+
name: Report licences in use (SPDX)
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v2
90+
- uses: actions/setup-python@v2
91+
- name: Determine dependencies
92+
# Note
93+
# The below code generates a pip requirements file from the pipenv development requirements (also obtaining the
94+
# normal dependencies from setup.py).
95+
# This code also forces the system to install latest tools as the ones present on the CI system may be too old
96+
# for the process to go through properly.
97+
run: |
98+
python -m pip install --upgrade pip wheel setuptools
99+
python -m pip install flake8 pipenv pytest
100+
python -m pipenv lock --dev -r --pre > dev-requirements.txt
101+
- uses: FranzDiebold/github-env-vars-action@v2
102+
- name: Load Python Dependencies from cache
103+
uses: actions/cache@v2
104+
with:
105+
path: ${{ env.python_cache_ubuntu_path }}
106+
key: linux-pip-3-continuous-delivery-scripts
107+
- name: Install dependencies
108+
# Note
109+
# As a virtual machine is already being used, pipenv
110+
# is superfluous and eliminating pipenv in CI reduces overhead and reduce complexity, while retaining a single
111+
# location for development dependencies.
112+
run: |
113+
python -m pip install -r dev-requirements.txt
114+
python -m pip list
115+
- name: Generate SPDX documents
116+
run: |
117+
mkdir -p ./spdx-tmp
118+
cd-generate-spdx --output-dir ./spdx-tmp
119+
- name: Add copyright/licence notice.
120+
run: |
121+
cd-license-files
122+
- uses: actions/upload-artifact@v2
123+
with:
124+
name: spdx
125+
path: ./spdx-tmp
126+
127+
detect-secrets:
128+
name: Check for secrets
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/setup-python@v2
132+
- name: Install tools
133+
run: |
134+
python -m pip install --upgrade pip
135+
python -m pip install detect-secrets==1.0.3
136+
python -m pip list
137+
- uses: actions/checkout@v2
138+
with:
139+
fetch-depth: 0
140+
- name: Check for secrets using gitleaks
141+
uses: zricethezav/gitleaks-action@master
142+
with:
143+
config-path: .gitleaks.toml
144+
- name: Check for secrets using detect-secrets
145+
run: |
146+
git ls-files -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline --exclude-files 'Pipfile\.lock$' --exclude-files '.*\.html$' --exclude-files '.*\.properties$' --exclude-files 'ci.yml' --exclude-files '\.git'
147+
working-directory: .
148+
17149
build-and-test:
18150
strategy:
19151
fail-fast: false
20152
matrix:
21153
os: [ubuntu-latest, macOS-latest, windows-latest]
22-
python-version: ["3.8", "3.9", "3.10"]
23-
go-module: [utils]
154+
python-version: ["3.7", "3.8", "3.9", "3.10"]
24155
multi-platform:
25156
- ${{ github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' }}
157+
# include:
158+
# - os: windows-latest
159+
# cache_path: ${{ env.python_cache_windows_path }}
160+
# - os: macOS-latest
161+
# cache_path: ${{ env.python_cache_macOS_path }}
162+
# - os: ubuntu-latest
163+
# cache_path: ${{ env.python_cache_ubuntu_path }}
26164
exclude:
27165
- os: macOS-latest
28166
multi-platform: false
167+
- os: macOS-latest
168+
python-version: 3.10
169+
- os: macOS-latest
170+
python-version: 3.8
171+
- os: macOS-latest
172+
python-version: 3.7
29173
- os: windows-latest
30174
multi-platform: false
175+
31176
name: Build and test
32-
runs-on: ${{ matrix.os }}
177+
runs-on: ${{ matrix.os }}
33178
steps:
34-
- uses: actions/checkout@v2
35-
- name: Set up Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@v2
37-
with:
38-
python-version: ${{ matrix.python-version }}
39-
- name: Determine dependencies [OS:${{ matrix.os }}, Python:${{ matrix.python-version }}]
40-
# Note
41-
# The below code generates a pip requirements file from the pipenv development requirements (also obtaining the
42-
# normal dependencies from setup.py).
43-
# This code also forces the system to install latest tools as the ones present on the CI system may be too old
44-
# for the process to go through properly.
45-
run: |
46-
python -m pip install --upgrade pip wheel setuptools
47-
python -m pip install flake8 pipenv pytest
48-
python -m pipenv lock --dev -r --pre > dev-requirements.txt
49-
50-
- if: ${{ startsWith(matrix.os, 'macOS') }}
51-
run: echo "CACHE_PATH=${{ env.python_cache_macOS_path }}" >> $GITHUB_ENV
52-
- if: ${{ startsWith(matrix.os, 'windows') }}
53-
run: echo "CACHE_PATH=${{ env.python_cache_windows_path }}" >> $GITHUB_ENV
54-
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
55-
run: echo "CACHE_PATH=${{ env.python_cache_ubuntu_path }}" >> $GITHUB_ENV
56-
- name: Load Python Dependencies from cache
57-
uses: actions/cache@v2
58-
with:
59-
path: |
60-
${{ env.CACHE_PATH }}
61-
~/go/pkg/mod
62-
key: ${{ matrix.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/dev-requirements.txt') }}
63-
restore-keys: |
64-
${{ matrix.os }}-pip-${{ matrix.python-version }}
65-
- name: Install dependencies
66-
# Note
67-
# As a virtual machine is already being used, pipenv
68-
# is superfluous and eliminating pipenv in CI reduces overhead and reduce complexity, while retaining a single
69-
# location for development dependencies.
70-
run: |
71-
python -m pip install -r dev-requirements.txt
72-
python -m pip list
73-
- name: Static Analysis - general (flake8)
74-
run: |
75-
flake8 --count --show-source --statistics
76-
- name: Test with pytest
77-
run: |
78-
pytest
79-
- name: Upload coverage reports to Codecov with GitHub Action
80-
uses: codecov/codecov-action@v2
179+
- uses: actions/checkout@v2
180+
- name: Set up Python ${{ matrix.python-version }}
181+
uses: actions/setup-python@v2
182+
with:
183+
python-version: ${{ matrix.python-version }}
184+
- name: Determine dependencies [OS:${{ matrix.os }}, Python:${{ matrix.python-version }}]
185+
# Note
186+
# The below code generates a pip requirements file from the pipenv development requirements (also obtaining the
187+
# normal dependencies from setup.py).
188+
# This code also forces the system to install latest tools as the ones present on the CI system may be too old
189+
# for the process to go through properly.
190+
run: |
191+
python -m pip install --upgrade pip wheel setuptools
192+
python -m pip install flake8 pipenv pytest
193+
python -m pipenv lock --dev -r --pre > dev-requirements.txt
194+
- if: ${{ startsWith(matrix.os, 'macOS') }}
195+
run: echo "CACHE_PATH=${{ env.python_cache_macOS_path }}" >> $GITHUB_ENV
196+
- if: ${{ startsWith(matrix.os, 'windows') }}
197+
run: echo "CACHE_PATH=${{ env.python_cache_windows_path }}" >> $GITHUB_ENV
198+
- if: ${{ startsWith(matrix.os, 'ubuntu') }}
199+
run: echo "CACHE_PATH=${{ env.python_cache_ubuntu_path }}" >> $GITHUB_ENV
200+
- name: Load Python Dependencies from cache
201+
uses: actions/cache@v2
202+
with:
203+
path: ${{ env.CACHE_PATH }}
204+
key: ${{ matrix.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/dev-requirements.txt') }}
205+
restore-keys: |
206+
${{ matrix.os }}-pip-${{ matrix.python-version }}
207+
# env:
208+
# CACHE_PATH: ${{ matrix.cache_path }}
209+
- name: Install dependencies
210+
# Note
211+
# As a virtual machine is already being used, pipenv
212+
# is superfluous and eliminating pipenv in CI reduces overhead and reduce complexity, while retaining a single
213+
# location for development dependencies.
214+
run: |
215+
python -m pip install -r dev-requirements.txt
216+
python -m pip list
217+
- name: Static Analysis - general (flake8)
218+
run: |
219+
flake8 --count --show-source --statistics
220+
- name: Test with pytest
221+
run: |
222+
pytest
223+
- name: Upload coverage reports to Codecov with GitHub Action
224+
uses: codecov/codecov-action@v2

.github/workflows/dependabot.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Dependabot
2+
on: pull_request_target
3+
permissions:
4+
pull-requests: write
5+
issues: write
6+
repository-projects: write
7+
contents: write
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
# Checkout with full history for to allow compare with base branch
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- uses: actions/setup-python@v2
18+
- uses: FranzDiebold/github-env-vars-action@v2
19+
- name: Install CI/CD tools
20+
run: |
21+
python -m pip install --upgrade pip
22+
python -m pip install continuous-delivery-scripts
23+
python -m pip list
24+
- name: Dependabot metadata
25+
id: dependabot-metadata
26+
uses: dependabot/[email protected]
27+
with:
28+
github-token: "${{ secrets.GITHUB_TOKEN }}"
29+
- name: Add a label
30+
run: gh pr edit "$PR_URL" --add-label "bot"
31+
env:
32+
PR_URL: ${{github.event.pull_request.html_url}}
33+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
34+
- name: Approve the PR
35+
run: gh pr review --approve "$PR_URL"
36+
env:
37+
PR_URL: ${{github.event.pull_request.html_url}}
38+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
39+
- name: Assert news
40+
run: cd-assert-news -b ${CI_ACTION_REF_NAME}
41+
env:
42+
GIT_TOKEN: ${{ secrets.GIT_SECRET }}
43+
- name: Auto-merge the PR
44+
run: gh pr merge --auto --squash --body "Dependency upgrade $PR_URL" --merge "$PR_URL"
45+
env:
46+
PR_URL: ${{github.event.pull_request.html_url}}
47+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: GitHub Release
2+
3+
env:
4+
go_version: "1.16"
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
release_type:
10+
description:
11+
"Enter type of release to perform (i.e. development, beta, release):"
12+
required: true
13+
jobs:
14+
release:
15+
name: Carry out a release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-python@v2
20+
- name: Determine dependencies
21+
# Note
22+
# The below code generates a pip requirements file from the pipenv development requirements (also obtaining the
23+
# normal dependencies from setup.py).
24+
# This code also forces the system to install latest tools as the ones present on the CI system may be too old
25+
# for the process to go through properly.
26+
run: |
27+
python -m pip install --upgrade pip wheel setuptools
28+
python -m pip install flake8 pipenv pytest
29+
python -m pipenv lock --dev -r --pre > dev-requirements.txt
30+
- uses: FranzDiebold/github-env-vars-action@v2
31+
- name: Load Python Dependencies from cache
32+
uses: actions/cache@v2
33+
with:
34+
path: ${{ env.python_cache_ubuntu_path }}
35+
key: linux-pip-3-continuous-delivery-scripts
36+
- name: Install dependencies
37+
# Note
38+
# As a virtual machine is already being used, pipenv
39+
# is superfluous and eliminating pipenv in CI reduces overhead and reduce complexity, while retaining a single
40+
# location for development dependencies.
41+
run: |
42+
python -m pip install -r dev-requirements.txt
43+
python -m pip list
44+
- name: Generate SPDX documents
45+
run: |
46+
mkdir -p ./spdx-tmp
47+
cd-generate-spdx --output-dir ./spdx-tmp
48+
- name: Generate Documentation
49+
run: |
50+
cd-generate-docs --output_dir $(cd-get-config --key DOCUMENTATION_PRODUCTION_OUTPUT_PATH)
51+
- name: Add copyright/licence notice.
52+
run: |
53+
cd-license-files
54+
- name: Tag and release
55+
run: cd-tag-and-release -b ${CI_ACTION_REF_NAME} -t ${{ github.event.inputs.release_type }} -vv
56+
env:
57+
# Using a specific token because GITHUB_TOKEN is not available https://github.com/marketplace/actions/workflow-dispatch#token
58+
GIT_TOKEN: ${{ secrets.GIT_SECRET }}
59+
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
60+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
61+
IGNORE_PYPI_TEST_UPLOAD: true

0 commit comments

Comments
 (0)