Skip to content

Commit 52f44e7

Browse files
committed
add Makefile and enable local CI tests
1 parent 8e87fff commit 52f44e7

File tree

11 files changed

+175
-109
lines changed

11 files changed

+175
-109
lines changed

.github/workflows/bandit.yml

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
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: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main
21+
- name: Simple bandit security checks
22+
run: make security
23+
- name: Show Report in Action Output
24+
if: always()
25+
run: cat bandit-report.json
26+
- name: Upload Bandit Scan Artifact
27+
uses: actions/upload-artifact@v4
28+
if: always()
29+
with:
30+
name: bandit-findings
31+
path: bandit-report.json

.github/workflows/black.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
10-
- uses: psf/black@stable
10+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main
11+
- run: make lint

.github/workflows/build.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,21 @@ 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: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main
21+
- name: Simple poetry build no package
22+
run: make build

.github/workflows/docs.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,15 @@ 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: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main
14+
- run: make docs
2315
- name: Deploy to GitHub Pages
2416
uses: peaceiris/actions-gh-pages@v4
2517
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

.github/workflows/pytests.yml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,10 @@ 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
20-
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)
13+
- uses: actions/checkout@v4
14+
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main
15+
- name: Run tests
2916
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"
3617
export GLOCI_REGISTRY_TOKEN="invalid"
37-
poetry run pytest -k "not kms"
38-
18+
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: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
$(POETRY) install --with dev
26+
27+
install-docs:
28+
$(POETRY) install --with dev,docs
29+
30+
test-deps:
31+
@if [ ! -f ./test-data/zot ]; then \
32+
if [ "$(shell uname)" = "Darwin" ] && [ "$(shell uname -m)" = "arm64" ]; then \
33+
curl -L -o ./test-data/zot https://github.com/project-zot/zot/releases/download/v2.1.0/zot-darwin-arm64; \
34+
elif [ "$(shell uname)" = "Linux" ] && [ "$(shell uname -m)" = "x86_64" ]; then \
35+
curl -L -o ./test-data/zot https://github.com/project-zot/zot/releases/download/v2.1.0/zot-linux-amd64; \
36+
else \
37+
echo "Unsupported platform or architecture"; \
38+
exit 1; \
39+
fi; \
40+
fi
41+
chmod +x ./test-data/zot
42+
rm -rf test-data/gardenlinux
43+
git submodule update --init --recursive
44+
45+
test: install-dev test-deps
46+
$(POETRY) run pytest -k "not kms"
47+
48+
format: install-dev
49+
$(POETRY) run black --extend-exclude test-data/gardenlinux .
50+
51+
lint: install-dev
52+
$(POETRY) run black --check --extend-exclude test-data/gardenlinux .
53+
54+
security: install-dev
55+
@if [ "$(CI)" = "true" ]; then \
56+
$(POETRY) run bandit -ll -ii -r . -f json -o bandit-report.json ; \
57+
else \
58+
$(POETRY) run bandit -r . ; \
59+
fi
60+
61+
docs: install-docs
62+
$(POETRY) run sphinx-build docs _build
63+
64+
clean:
65+
rm -rf build/
66+
rm -rf dist/
67+
rm -rf *.egg-info/
68+
rm -rf .eggs/
69+
rm -rf .pytest_cache/
70+
rm -rf .coverage
71+
rm -rf htmlcov/
72+
find . -type d -name __pycache__ -exec rm -rf {} +
73+
find . -type f -name "*.pyc" -delete
74+
find . -type f -name "*.pyo" -delete
75+
find . -type f -name "*.pyd" -delete
76+
rm -rf test-data/zot
77+
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() {

test-data/build-test-data.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
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
33
echo "This will take a while. Building for the following targets:"
44

0 commit comments

Comments
 (0)