Skip to content

Commit bdb9f2c

Browse files
committed
Initial commit, copy of cf-remote
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
0 parents  commit bdb9f2c

39 files changed

+6243
-0
lines changed

.github/workflows/black-format.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Automatically format with Black and submit PR
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
workflow_dispatch:
9+
10+
jobs:
11+
format:
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- name: Checks-out repository
15+
uses: actions/checkout@v4
16+
- name: Set up Python 3.12
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
- name: Install black
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install black
24+
- name: Reformat with black
25+
run: |
26+
shopt -s globstar
27+
black cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py > black_output.txt 2>&1
28+
- name: Check if there are changes
29+
run: |
30+
git diff --exit-code || touch git_diff_exists
31+
if [ -f git_diff_exists ]; then echo "Changes need to be commited"; else echo "No changes to commit"; fi
32+
- name: Create commit message
33+
if: hashFiles('git_diff_exists') != ''
34+
run: |
35+
echo "Reformatted python code using Black formatter" >> commit_message.txt
36+
echo "" >> commit_message.txt
37+
echo "Output from black:" >> commit_message.txt
38+
echo "" >> commit_message.txt
39+
echo '```' >> commit_message.txt
40+
cat black_output.txt >> commit_message.txt
41+
echo '```' >> commit_message.txt
42+
- name: Commit changes
43+
if: hashFiles('git_diff_exists') != ''
44+
run: |
45+
git config user.name 'GitHub'
46+
git config user.email '<noreply@github.com>'
47+
shopt -s globstar
48+
git add cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py
49+
git commit -F commit_message.txt
50+
- id: commit-message-from-file
51+
name: Parse commit message from file into variable
52+
if: hashFiles('git_diff_exists') != ''
53+
run: |
54+
body=$(cat commit_message.txt)
55+
body="${body//$'\n'/'%0A'}"
56+
echo ::set-output name=body::$body
57+
- name: Create Pull Request
58+
if: hashFiles('git_diff_exists') != ''
59+
uses: cfengine/create-pull-request@v6
60+
with:
61+
title: Reformatted python code using Black formatter
62+
body: ${{ steps.commit-message-from-file.outputs.body }}
63+
reviewers: |
64+
olehermanse
65+
larsewi
66+
vpodzime
67+
branch: formatting-action

.github/workflows/black.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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: Black
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
check:
14+
runs-on: ubuntu-20.04
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
python-version: [3.12]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install black
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Check formatting with black
32+
run: |
33+
shopt -s globstar
34+
black --check cf_remote/*.py cf_remote/**/*.py tests/*.py tests/**/*.py
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install setuptools wheel twine
25+
- name: Build and publish
26+
env:
27+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
29+
run: |
30+
git fetch --all --tags
31+
python setup.py sdist bdist_wheel
32+
twine upload dist/*

.github/workflows/tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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: Tests
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
python_version:
14+
runs-on: ubuntu-20.04
15+
env:
16+
# Temporary workaround for Python 3.5 failures - May 2024, see CFE-4395
17+
PIP_TRUSTED_HOST: "pypi.python.org pypi.org files.pythonhosted.org"
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
- name: Set up Python ${{ matrix.python-version }}
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ matrix.python-version }}
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
python -m pip install flake8 pytest setuptools wheel
35+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
36+
- name: Lint with flake8
37+
run: |
38+
# stop the build if there are Python syntax errors or undefined names
39+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
40+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
41+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
42+
- name: Test with pytest
43+
run: |
44+
pytest
45+
- name: Install
46+
run: |
47+
python setup.py sdist bdist_wheel
48+
pip install dist/cf_remote-*.whl
49+
- name: Sanity check
50+
run: cf-remote -V
51+
- name: Run docker test
52+
run: |
53+
bash tests/docker/0*.sh
54+
- name: Run unsafe tests
55+
run: |
56+
bash tests/unsafe/0*.sh

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build
2+
dist
3+
/cf_remote/VERSION
4+
/cf_remote/__pycache__/
5+
/cf_remote.egg-info/
6+
/venv
7+
/.venv
8+
__pycache__/
9+
**/.DS_STORE

0 commit comments

Comments
 (0)