Skip to content

Commit 40f9c51

Browse files
committed
add Makefile and enable local CI tests
1 parent 8e87fff commit 40f9c51

File tree

14 files changed

+1244
-198
lines changed

14 files changed

+1244
-198
lines changed

.github/actions/setup/action.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
name: python_lib
22
description: Installs the given GardenLinux Python library
33
inputs:
4-
version:
5-
description: GardenLinux Python library version
6-
default: "main"
4+
version:
5+
description: GardenLinux Python library version
6+
default: "main"
7+
dev:
8+
description: Install development dependencies
9+
default: false
710
runs:
8-
using: composite
9-
steps:
10-
- name: Set up Python 3.13
11-
uses: actions/setup-python@v5
12-
with:
13-
python-version: "3.13"
14-
- name: Install GardenLinux Python library
15-
shell: bash
16-
run: |
17-
pip install git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }}
11+
using: composite
12+
steps:
13+
- name: Set up Python 3.13
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.13"
17+
- name: Install GardenLinux Python library
18+
shell: bash
19+
run: |
20+
pip install git+https://github.com/gardenlinux/python-gardenlinux-lib.git@${{ inputs.version }}
21+
- name: Install GardenLinux Python library
22+
if: inputs.dev == true
23+
shell: bash
24+
run: |
25+
make install-dev

.github/workflows/bandit.yml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,33 @@
11
name: security checks
22
on:
3-
push:
4-
paths-ignore:
5-
- 'README.md'
6-
- 'docs/**'
7-
- '**/README.md'
8-
pull_request:
9-
paths-ignore:
10-
- 'README.md'
11-
- 'docs/**'
12-
- '**/README.md'
3+
push:
4+
paths-ignore:
5+
- "README.md"
6+
- "docs/**"
7+
- "**/README.md"
8+
pull_request:
9+
paths-ignore:
10+
- "README.md"
11+
- "docs/**"
12+
- "**/README.md"
1313
permissions:
14-
contents: read
14+
contents: read
1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v4
20-
- uses: actions/setup-python@v5
21-
with:
22-
python-version: "3.12"
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install bandit
27-
28-
- name: Simple bandit security checks
29-
run: bandit -ll -ii -r . -f json -o bandit-report.json
30-
31-
- name: Show Report in Action Output
32-
if: always()
33-
run: cat bandit-report.json
34-
35-
- name: Upload Bandit Scan Artifact
36-
uses: actions/upload-artifact@v4
37-
if: always()
38-
with:
39-
name: bandit-findings
40-
path: bandit-report.json
41-
19+
- uses: actions/checkout@v4
20+
- uses: .github/actions/setup/action.yml
21+
with:
22+
dev: true
23+
- name: Simple bandit security checks
24+
run: make security
25+
- name: Show Report in Action Output
26+
if: always()
27+
run: cat bandit-report.json
28+
- name: Upload Bandit Scan Artifact
29+
uses: actions/upload-artifact@v4
30+
if: always()
31+
with:
32+
name: bandit-findings
33+
path: bandit-report.json

.github/workflows/black.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
10-
- uses: psf/black@stable
10+
- uses: .github/actions/setup/action.yml
11+
with:
12+
dev: true
13+
- run: make lint

.github/workflows/build.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,23 @@ name: Build
22
on:
33
push:
44
paths-ignore:
5-
- 'README.md'
6-
- 'docs/**'
7-
- '**/README.md'
5+
- "README.md"
6+
- "docs/**"
7+
- "**/README.md"
88
pull_request:
99
paths-ignore:
10-
- 'README.md'
11-
- 'docs/**'
12-
- '**/README.md'
10+
- "README.md"
11+
- "docs/**"
12+
- "**/README.md"
1313
permissions:
1414
contents: read
1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v4
20-
- uses: actions/setup-python@v5
21-
with:
22-
python-version: "3.12"
23-
- name: Install dependencies
24-
run: |
25-
python -m pip install --upgrade pip
26-
pip install poetry
27-
- name: Simple poetry build no package
28-
run: poetry build
29-
19+
- uses: actions/checkout@v4
20+
- uses: .github/actions/setup/action.yml
21+
with:
22+
dev: true
23+
- name: Simple poetry build no package
24+
run: make build

.github/workflows/docs.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@ name: Update Sphinx documentation
33
on: [push, pull_request, workflow_dispatch]
44

55
permissions:
6-
contents: write
6+
contents: write
77

88
jobs:
99
docs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: actions/setup-python@v5
14-
- name: Install dependencies
15-
run: |
16-
pip install sphinx poetry
17-
- name: Sphinx build
18-
run: |
19-
python -m venv venv
20-
source venv/bin/activate
21-
poetry install
22-
sphinx-build docs _build
13+
- uses: .github/actions/setup/action.yml
14+
with:
15+
dev: true
16+
- run: make docs
2317
- name: Deploy to GitHub Pages
2418
uses: peaceiris/actions-gh-pages@v4
2519
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

.github/workflows/pytests.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,12 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12-
1312
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v4
16-
with:
17-
submodules: 'true'
18-
- name: Set up Python
19-
uses: actions/setup-python@v5
13+
- uses: actions/checkout@v4
14+
- uses: .github/actions/setup/action.yml
2015
with:
21-
python-version: '3.12'
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install poetry
26-
- name: Install dependencies
27-
run: poetry install
28-
- name: Install Zot (OCI Registry)
16+
dev: true
17+
- name: Run tests
2918
run: |
30-
sudo wget -O /usr/bin/zot https://github.com/project-zot/zot/releases/download/v2.1.0/zot-linux-amd64
31-
sudo chmod +x /usr/bin/zot
32-
sudo chown root:root /usr/bin/zot
33-
- name: Run tests with pytest
34-
run: |
35-
export GLOCI_REGISTRY_USERNAME="gardenlinux"
3619
export GLOCI_REGISTRY_TOKEN="invalid"
37-
poetry run pytest -k "not kms"
38-
20+
make test

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,9 @@ cython_debug/
162162
# and can be added to the global gitignore or merged into this file. For a more nuclear
163163
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
164164
.idea/
165+
166+
# bandit
167+
bandit-report.json
168+
169+
# zot
170+
test-data/zot

Makefile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
.PHONY: build install install-dev install-docs test format lint security docs clean help
2+
3+
POETRY := poetry
4+
5+
help:
6+
@echo "Available targets:"
7+
@echo " build - Build the package"
8+
@echo " install - Install the package and dependencies"
9+
@echo " install-dev - Install the package and dev dependencies"
10+
@echo " test - Run tests"
11+
@echo " format - Format code with black"
12+
@echo " lint - Run linting checks"
13+
@echo " security - Run security checks with bandit"
14+
@echo " docs - Build the documentation"
15+
@echo " clean - Clean build artifacts and cache"
16+
@echo " help - Show this help message"
17+
18+
build:
19+
$(POETRY) build
20+
21+
install:
22+
$(POETRY) install
23+
24+
install-dev:
25+
which $(POETRY) || pip install poetry
26+
$(POETRY) install --with dev
27+
28+
install-docs:
29+
$(POETRY) install --with dev,docs
30+
31+
test-deps:
32+
@if [ ! -f ./test-data/zot ]; then \
33+
if [ "$(shell uname)" = "Darwin" ] && [ "$(shell uname -m)" = "arm64" ]; then \
34+
curl -L -o ./test-data/zot https://github.com/project-zot/zot/releases/download/v2.1.0/zot-darwin-arm64; \
35+
elif [ "$(shell uname)" = "Linux" ] && [ "$(shell uname -m)" = "x86_64" ]; then \
36+
curl -L -o ./test-data/zot https://github.com/project-zot/zot/releases/download/v2.1.0/zot-linux-amd64; \
37+
else \
38+
echo "Unsupported platform or architecture"; \
39+
exit 1; \
40+
fi; \
41+
fi
42+
chmod +x ./test-data/zot
43+
rm -rf test-data/gardenlinux
44+
git submodule update --init --recursive
45+
46+
test: install-dev test-deps
47+
$(POETRY) run pytest -k "not kms"
48+
49+
format: install-dev
50+
$(POETRY) run black --extend-exclude test-data/gardenlinux .
51+
52+
lint: install-dev
53+
$(POETRY) run black --check --extend-exclude test-data/gardenlinux .
54+
55+
security: install-dev
56+
@if [ "$(CI)" = "true" ]; then \
57+
$(POETRY) run bandit -ll -ii -r . -f json -o bandit-report.json ; \
58+
else \
59+
$(POETRY) run bandit -r . ; \
60+
fi
61+
62+
docs: install-docs
63+
$(POETRY) run sphinx-build docs _build
64+
65+
clean:
66+
rm -rf build/
67+
rm -rf dist/
68+
rm -rf *.egg-info/
69+
rm -rf .eggs/
70+
rm -rf .pytest_cache/
71+
rm -rf .coverage
72+
rm -rf htmlcov/
73+
find . -type d -name __pycache__ -exec rm -rf {} +
74+
find . -type f -name "*.pyc" -delete
75+
find . -type f -name "*.pyo" -delete
76+
find . -type f -name "*.pyd" -delete
77+
rm -rf test-data/zot
78+
cd test-data/gardenlinux && git reset --hard

cert/gencert.sh

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

hack/print_feature_extensions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33

44
search_and_print_directories() {

0 commit comments

Comments
 (0)