Skip to content

Commit 80438dd

Browse files
authored
Merge pull request #24 from plugwise/quality
Improve code styling-quality and migrate to GitHub actions
2 parents 9e3809d + 689b132 commit 80438dd

30 files changed

+711
-263
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
# ******** NOTE ********
12+
13+
name: "CodeQL"
14+
15+
on:
16+
# push:
17+
# branches: [ main ]
18+
# pull_request:
19+
# # The branches below must be a subset of the branches above
20+
# branches: [ main ]
21+
schedule:
22+
- cron: '24 14 * * 5'
23+
24+
jobs:
25+
analyze:
26+
name: Analyze
27+
runs-on: ubuntu-latest
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
language: [ 'python' ]
33+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
34+
# Learn more...
35+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v2
40+
41+
# Initializes the CodeQL tools for scanning.
42+
- name: Initialize CodeQL
43+
uses: github/codeql-action/init@v1
44+
with:
45+
languages: ${{ matrix.language }}
46+
# If you wish to specify custom queries, you can do so here or in a config file.
47+
# By default, queries listed here will override any specified in a config file.
48+
# Prefix the list here with "+" to use these queries and those in the config file.
49+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
50+
51+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
52+
# If this step fails, then you should remove it and run the build manually (see below)
53+
- name: Autobuild
54+
uses: github/codeql-action/autobuild@v1
55+
56+
# ℹ️ Command-line programs to run using the OS shell.
57+
# 📚 https://git.io/JvXDl
58+
59+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
60+
# and modify them (or add more) to build your code if your project
61+
# uses a compiled language
62+
63+
#- run: |
64+
# make bootstrap
65+
# make release
66+
67+
- name: Perform CodeQL Analysis
68+
uses: github/codeql-action/analyze@v1
69+

.github/workflows/merge.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Latest release
5+
6+
env:
7+
CACHE_VERSION: 1
8+
DEFAULT_PYTHON: 3.9
9+
PRE_COMMIT_HOME: ~/.cache/pre-commit
10+
11+
# Only run on merges
12+
on:
13+
pull_request:
14+
types: closed
15+
branches:
16+
- main
17+
18+
jobs:
19+
# Prepare default python version environment
20+
prepare:
21+
runs-on: ubuntu-latest
22+
name: Prepare
23+
steps:
24+
- name: Check out committed code
25+
uses: actions/checkout@v2
26+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
27+
id: python
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: ${{ env.DEFAULT_PYTHON }}
31+
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
32+
id: cache-venv
33+
uses: actions/cache@v2
34+
with:
35+
path: venv
36+
key: >-
37+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
38+
steps.python.outputs.python-version }}-${{
39+
hashFiles('requirements_test.txt') }}-${{
40+
hashFiles('setup.py') }}
41+
restore-keys: |
42+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }}-${{ hashFiles('setup.py') }}-
43+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-${{ hashFiles('requirements_test.txt') }}
44+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{ steps.python.outputs.python-version }}-
45+
- name: Create Python virtual environment
46+
if: steps.cache-venv.outputs.cache-hit != 'true'
47+
run: |
48+
python -m venv venv
49+
. venv/bin/activate
50+
pip install -U pip setuptools
51+
pip install -e .
52+
pip install -r requirements_test.txt
53+
- name: Restore pre-commit environment from cache
54+
id: cache-precommit
55+
uses: actions/cache@v2
56+
with:
57+
path: ${{ env.PRE_COMMIT_HOME }}
58+
key: |
59+
${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
60+
restore-keys: |
61+
${{ env.CACHE_VERSION}}-${{ runner.os }}-pre-commit-
62+
- name: Install pre-commit dependencies
63+
if: steps.cache-precommit.outputs.cache-hit != 'true'
64+
run: |
65+
. venv/bin/activate
66+
pre-commit install-hooks
67+
68+
publishing:
69+
name: Build and publish Python 🐍 distributions 📦 to PyPI
70+
runs-on: ubuntu-latest
71+
needs: prepare
72+
# Only trigger on merges, not just closes
73+
if: github.event.pull_request.merged == true
74+
steps:
75+
- name: Check out committed code
76+
uses: actions/checkout@main
77+
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
78+
id: python
79+
uses: actions/setup-python@v2
80+
with:
81+
python-version: ${{ env.DEFAULT_PYTHON }}
82+
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
83+
id: cache-venv
84+
uses: actions/cache@v2
85+
with:
86+
path: venv
87+
key: >-
88+
${{ env.CACHE_VERSION}}-${{ runner.os }}-base-venv-${{
89+
steps.python.outputs.python-version }}-${{
90+
hashFiles('requirements_test.txt') }}-${{
91+
hashFiles('setup.py') }}
92+
- name: Fail job if Python cache restore failed
93+
if: steps.cache-venv.outputs.cache-hit != 'true'
94+
run: |
95+
echo "Failed to restore Python virtual environment from cache"
96+
exit 1
97+
- name: Build a distribution
98+
run: >-
99+
python setup.py sdist
100+
- name: Publish distribution 📦 to Test PyPI
101+
uses: pypa/gh-action-pypi-publish@master
102+
with:
103+
password: ${{ secrets.pypi_token }}
104+
skip_existing: true

.github/workflows/publish-to-test-pypi.yml

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

0 commit comments

Comments
 (0)