Skip to content

Commit 476fe28

Browse files
authored
feat: switch from make to nox (#73)
* feat: swith from make to nox * docs: update docstring * fix: install nox
1 parent aa48a70 commit 476fe28

File tree

4 files changed

+62
-33
lines changed

4 files changed

+62
-33
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,13 @@ jobs:
106106

107107
- name: Install Dependencies
108108
run: |
109-
sudo apt-get update
110-
sudo apt-get install -y gnuplot
109+
pip install nox
110+
nox -s install-deps
111111
112112
- name: Generate GitStats Report
113113
run: |
114-
python3 -m venv venv
115-
source venv/bin/activate
116-
# for testing
117-
pip install .
118-
gitstats . gitstats-report -f json
114+
pip install nox
115+
nox -s build
119116
120117
- name: Save GitStats Report
121118
if: ${{ matrix.python-version == '3.9' }}

.gitpod.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66

77
tasks:
88
- name: Install & Build
9-
init: make install-deps && make build
10-
command: make preview
9+
init: |
10+
pip install nox
11+
nox -s install-deps
12+
nox -s build
13+
command: nox -s preview

Makefile

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

noxfile.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import nox
2+
import shutil
3+
from pathlib import Path
4+
5+
# Default tag for docker images
6+
TAG = "latest"
7+
8+
9+
@nox.session
10+
def image(session: nox.Session) -> None:
11+
"""Build docker image"""
12+
session.run("docker", "build", "-t", f"gitstats:{TAG}", ".", external=True)
13+
14+
15+
@nox.session
16+
def publish_image(session: nox.Session) -> None:
17+
"""Publish docker image to ghcr"""
18+
image(session) # Build the image first
19+
session.run(
20+
"docker",
21+
"tag",
22+
f"gitstats:{TAG}",
23+
f"ghcr.io/shenxianpeng/gitstats:{TAG}",
24+
external=True,
25+
)
26+
session.run("docker", "push", f"ghcr.io/shenxianpeng/gitstats:{TAG}", external=True)
27+
28+
29+
@nox.session(name="install-deps")
30+
def install_deps(session: nox.Session) -> None:
31+
"""Install gnuplot"""
32+
session.run("sudo", "apt", "update", "-y", external=True)
33+
session.run("sudo", "apt", "install", "gnuplot", "-y", external=True)
34+
35+
36+
@nox.session
37+
def build(session: nox.Session) -> None:
38+
"""Generate gitstats report and json file"""
39+
report_dir = Path("test-report")
40+
if report_dir.exists():
41+
shutil.rmtree(report_dir)
42+
session.install("--upgrade", "pip")
43+
session.install("-e", ".")
44+
session.run("gitstats", ".", str(report_dir), "-f", "json", external=True)
45+
46+
47+
@nox.session
48+
def preview(session: nox.Session) -> None:
49+
"""Preview gitstats report in local"""
50+
build(session) # Generate report first
51+
session.run(
52+
"python3", "-m", "http.server", "8000", "-d", "test-report", external=True
53+
)

0 commit comments

Comments
 (0)