Compare commits
60 commits
a0a64a098f
...
4ba599b2fe
Author | SHA1 | Date | |
---|---|---|---|
4ba599b2fe | |||
b6e8dfbec6 | |||
7ebbedc136 | |||
1045053b32 | |||
399bd1960e | |||
f9567f68ba | |||
dae283892c | |||
101e3cf220 | |||
d703770f71 | |||
2670bec22e | |||
fd505e93e6 | |||
fc2fb7581b | |||
c940dab9b5 | |||
c427cf60ce | |||
849d1ef1bf | |||
dfd4219191 | |||
128c2ef986 | |||
dcbb88b423 | |||
eae12292c3 | |||
64ec49dbc7 | |||
ca175d805a | |||
ba636d5fc7 | |||
f1f3503c95 | |||
7f5b6ebbf9 | |||
beadc87c94 | |||
8f6b4772a2 | |||
07398c07ab | |||
8e48406c81 | |||
9b735fe556 | |||
5112abf37e | |||
ef00f4aa97 | |||
a0c36dba7c | |||
ff7c6b17d8 | |||
776421884b | |||
e6d631994e | |||
7dc9f06e47 | |||
aff3a8180a | |||
eb8fd0b651 | |||
493f50bdd0 | |||
6046ebe441 | |||
aeeb047b36 | |||
c7c0d7c7d7 | |||
c77674afa4 | |||
886fcf3673 | |||
924e44a9d9 | |||
c481b2168c | |||
a4c2272b2f | |||
44423ef2ee | |||
588bf5c6c4 | |||
f9c8cbc59e | |||
192692ec8a | |||
12f235af81 | |||
3001e6ec30 | |||
dbb27ac0ef | |||
2ddbc2d090 | |||
3f41f0c6b1 | |||
9cb23cfff1 | |||
3e494bc354 | |||
52835704bf | |||
bc1d047359 |
8 changed files with 225 additions and 75 deletions
|
@ -2,6 +2,7 @@ on: [push]
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
alpine:
|
alpine:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ${{vars.DOCKER}}alpine:3.19
|
image: ${{vars.DOCKER}}alpine:3.19
|
||||||
steps:
|
steps:
|
||||||
|
@ -16,6 +17,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
debian:
|
debian:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: alpine
|
needs: alpine
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -32,6 +34,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
ubuntu:
|
ubuntu:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: debian
|
needs: debian
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -48,6 +51,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
arch:
|
arch:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: ubuntu
|
needs: ubuntu
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -64,6 +68,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
opensuse:
|
opensuse:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: arch
|
needs: arch
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -80,6 +85,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
fedora:
|
fedora:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: opensuse
|
needs: opensuse
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -96,6 +102,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
alma:
|
alma:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: fedora
|
needs: fedora
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -112,6 +119,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
rocky:
|
rocky:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: alma
|
needs: alma
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
|
|
@ -2,6 +2,7 @@ on: [push]
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
alpine:
|
alpine:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ${{vars.DOCKER}}alpine:3.20
|
image: ${{vars.DOCKER}}alpine:3.20
|
||||||
steps:
|
steps:
|
||||||
|
@ -16,6 +17,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
debian:
|
debian:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: alpine
|
needs: alpine
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -35,6 +37,7 @@ jobs:
|
||||||
- run: spcd-synchronize
|
- run: spcd-synchronize
|
||||||
|
|
||||||
ubuntu:
|
ubuntu:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: debian
|
needs: debian
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -51,6 +54,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
arch:
|
arch:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: ubuntu
|
needs: ubuntu
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -67,6 +71,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
opensuse:
|
opensuse:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: arch
|
needs: arch
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -83,6 +88,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
fedora:
|
fedora:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: opensuse
|
needs: opensuse
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -99,6 +105,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
alma:
|
alma:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: fedora
|
needs: fedora
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
@ -115,6 +122,7 @@ jobs:
|
||||||
- run: spcd-browse-workspace
|
- run: spcd-browse-workspace
|
||||||
|
|
||||||
rocky:
|
rocky:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
needs: alma
|
needs: alma
|
||||||
if: failure() || success()
|
if: failure() || success()
|
||||||
container:
|
container:
|
||||||
|
|
|
@ -18,7 +18,7 @@ dependencies = ["rwx"]
|
||||||
description = "Shell to Python Continuous Deployment"
|
description = "Shell to Python Continuous Deployment"
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
keywords = []
|
keywords = []
|
||||||
license-files = { paths = ["license.md"] }
|
license-files = ["license.md"]
|
||||||
name = "spcd"
|
name = "spcd"
|
||||||
readme = "readme.md"
|
readme = "readme.md"
|
||||||
requires-python = ">= 3.11"
|
requires-python = ">= 3.11"
|
||||||
|
|
86
readme.md
86
readme.md
|
@ -54,9 +54,10 @@ Picture it…
|
||||||
* [X] installing Git to clone
|
* [X] installing Git to clone
|
||||||
* [X] this project
|
* [X] this project
|
||||||
* [X] its parent framework
|
* [X] its parent framework
|
||||||
* [X] installing both Python
|
* [X] installing Python
|
||||||
* [X] system environment
|
* [X] system environment
|
||||||
* [X] virtual environment
|
* [X] virtual environment
|
||||||
|
* [ ] managed version
|
||||||
* [X] generating a Python module to switch context
|
* [X] generating a Python module to switch context
|
||||||
|
|
||||||
#### Python
|
#### Python
|
||||||
|
@ -95,30 +96,16 @@ Handle project workflows in a unified way:
|
||||||
* [ ] SourceHut
|
* [ ] SourceHut
|
||||||
|
|
||||||
* whatever the Operating System container
|
* whatever the Operating System container
|
||||||
* [X] Alma
|
| System | Latest | Previous |
|
||||||
* [X] 9
|
|:---------|:---------------------------|:---------------------------|
|
||||||
* [X] 8
|
| Alma | * [X] 9 | * [X] 8 |
|
||||||
* [X] Alpine
|
| Alpine | * [X] 3.20 | * [X] 3.19 |
|
||||||
* [X] 3.20
|
| Arch | * [X] 20240818 (.0.255804) | * [X] 20240101 (.0.204074) |
|
||||||
* [X] 3.19
|
| Debian | * [X] Bookworm (12) | * [ ] Bullseye (11) |
|
||||||
* [X] Arch
|
| Fedora | * [X] 40 | * [X] 39 |
|
||||||
* [X] 20240818 (.0.255804)
|
| OpenSUSE | * [ ] 15.6 | * [ ] 15.5 |
|
||||||
* [X] 20240101 (.0.204074)
|
| Rocky | * [X] 9 | * [X] 8 |
|
||||||
* [X] Debian
|
| Ubuntu | * [X] Noble (24.04) | * [ ] Jammy (22.04) |
|
||||||
* [X] Bookworm (12)
|
|
||||||
* [ ] Bullseye (11)
|
|
||||||
* [X] Fedora
|
|
||||||
* [X] 40
|
|
||||||
* [X] 39
|
|
||||||
* [ ] OpenSUSE
|
|
||||||
* [ ] 15.6
|
|
||||||
* [ ] 15.5
|
|
||||||
* [X] Rocky
|
|
||||||
* [X] 9
|
|
||||||
* [X] 8
|
|
||||||
* [X] Ubuntu
|
|
||||||
* [X] Noble (24.04)
|
|
||||||
* [ ] Jammy (22.04)
|
|
||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
|
@ -129,6 +116,7 @@ Handle project workflows in a unified way:
|
||||||
| SPCD_GIT_RWX | RWX Git repository | rwx |
|
| SPCD_GIT_RWX | RWX Git repository | rwx |
|
||||||
| SPCD_GIT_SHUNIT | ShUnit Git repository | shunit2 |
|
| SPCD_GIT_SHUNIT | ShUnit Git repository | shunit2 |
|
||||||
| SPCD_GIT_SPCD | SPCD Git repository | spcd |
|
| SPCD_GIT_SPCD | SPCD Git repository | spcd |
|
||||||
|
| SPCD_REF_ARCHIVE | Archive deployment ref | old |
|
||||||
| SPCD_REF_FEATURE | Feature deployment ref | f |
|
| SPCD_REF_FEATURE | Feature deployment ref | f |
|
||||||
| SPCD_REF_RELEASE | Release deployment ref | main |
|
| SPCD_REF_RELEASE | Release deployment ref | main |
|
||||||
| SPCD_REF_STAGING | Staging deployment ref | dev |
|
| SPCD_REF_STAGING | Staging deployment ref | dev |
|
||||||
|
@ -150,44 +138,40 @@ Handle project workflows in a unified way:
|
||||||
|
|
||||||
#### Latest
|
#### Latest
|
||||||
|
|
||||||
| os | https | up ca | python | graphviz | plantuml | shellcheck | shunit | shfmt | gource | ffmpeg |
|
| os | https | up ca | python | ffmpeg | gource | graphviz | plantuml | shellcheck | shfmt | shunit |
|
||||||
|:----------------|---|---|------------:|------:|-----------:|------:|------:|-----:|-----:|-------:|
|
|:----------------|---|---|------------:|-------:|-----:|------:|-----------:|------:|-----:|------:|
|
||||||
| Arch 20240818 | ☑ | ☑ | 3.12 | 12.0 | 1.2023.13 | 0.10 | 2.1.8 | 3.8 | 0.54 | 7.0.2 |
|
| Arch 20240818 | ☑ | ☑ | 3.12 | 7.0.2 | 0.54 | 12.0 | 1.2023.13 | 0.10 | 3.8 | 2.1.8 |
|
||||||
| Alpine 3.20 | ☑ | ☐ | 3.12 | 9.0 | 1.2024.4 | 0.10 | 2.1.8 | 3.8 | 0.54 | 6.1.1 |
|
| Alpine 3.20 | ☑ | ☐ | 3.12 | 6.1.1 | 0.54 | 9.0 | 1.2024.4 | 0.10 | 3.8 | 2.1.8 |
|
||||||
| Fedora 40 | ☑ | ☑ | 3.12 → 3.13 | 9.0 | 1.2024.6 | 0.9 | 2.1.6 | 3.7 | 0.55 | 6.1.2 |
|
| Fedora 40 | ☑ | ☑ | 3.12 → 3.13 | 6.1.2 | 0.55 | 9.0 | 1.2024.6 | 0.9 | 3.7 | 2.1.6 |
|
||||||
| Debian Bookworm | ☐ | ☐ | 3.11 | 2.42 | 1.2020.2 | 0.9 | 2.1.8 | 3.6 | 0.54 | 5.1.6 |
|
| Debian Bookworm | ☐ | ☐ | 3.11 | 5.1.6 | 0.54 | 2.42 | 1.2020.2 | 0.9 | 3.6 | 2.1.8 |
|
||||||
| OpenSUSE 15.6 | ☐ | ☑ | 3.6 → 3.12 | 2.48 | 1.2020.9 | 0.8 | 2.1.6 | 3.5 | 0.54 | 4.4.4 |
|
| OpenSUSE 15.6 | ☐ | ☑ | 3.6 → 3.12 | 4.4.4 | 0.54 | 2.48 | 1.2020.9 | 0.8 | 3.5 | 2.1.6 |
|
||||||
| Ubuntu Noble | ☐ | ☐ | 3.12 | u2.42 | u1.2020.2 | u0.9 | 2.1.8 | u3.8 | 0.54 | 6.1.1 |
|
| Ubuntu Noble | ☐ | ☐ | 3.12 | 6.1.1 | 0.54 | u2.42 | u1.2020.2 | u0.9 | u3.8 | 2.1.8 |
|
||||||
| Alma / Rocky 9 | ☑ | ☑ | 3.9 → 3.12 | 2.44 | e1.2024.6 | e0.8 | | | | e5.1.4 |
|
| Alma / Rocky 9 | ☑ | ☑ | 3.9 → 3.12 | e5.1.4 | | 2.44 | e1.2024.6 | e0.8 | | |
|
||||||
|
|
||||||
#### Previous
|
#### Previous
|
||||||
|
|
||||||
| os | https | up ca | python | graphviz | plantuml | shellcheck | shunit | shfmt | gource | ffmpeg |
|
| os | https | up ca | python | ffmpeg | gource | graphviz | plantuml | shellcheck | shfmt | shunit |
|
||||||
|:----------------|---|---|------------:|------:|-----------:|------:|------:|-----:|-----:|-------:|
|
|:----------------|---|---|------------:|-------:|-----:|------:|-----------:|------:|-----:|------:|
|
||||||
| Alpine 3.19 | ☑ | ☐ | 3.11 | 9.0 | 1.2023.12 | 0.9 | 2.1.8 | 3.7 | 0.54 | 6.1.1 |
|
| Alpine 3.19 | ☑ | ☐ | 3.11 | 6.1.1 | 0.54 | 9.0 | 1.2023.12 | 0.9 | 3.7 | 2.1.8 |
|
||||||
| Fedora 39 | ☑ | ☑ | 3.12 → 3.13 | 8.1 | 1.2024.6 | 0.9 | 2.1.6 | 3.5 | 0.55 | 6.1.1 |
|
| Fedora 39 | ☑ | ☑ | 3.12 → 3.13 | 6.1.1 | 0.55 | 8.1 | 1.2024.6 | 0.9 | 3.5 | 2.1.6 |
|
||||||
| OpenSUSE 15.5 | ☐ | ☑ | 3.6 → 3.11 | 2.48 | 1.2020.9 | 0.8 | 2.1.6 | 3.5 | 0.54 | 4.4.4 |
|
| OpenSUSE 15.5 | ☐ | ☑ | 3.6 → 3.11 | 4.4.4 | 0.54 | 2.48 | 1.2020.9 | 0.8 | 3.5 | 2.1.6 |
|
||||||
| Alma / Rocky 8 | ☑ | ☑ | 3.6 → 3.12 | 2.40 | e1.2024.6 | e0.6 | | | | |
|
| Alma / Rocky 8 | ☑ | ☑ | 3.6 → 3.12 | | | 2.40 | e1.2024.6 | e0.6 | | |
|
||||||
|
|
||||||
#### Older Python
|
#### Older Python
|
||||||
|
|
||||||
| os | https | up ca | python | graphviz | plantuml | shellcheck | shunit | shfmt | gource | ffmpeg |
|
| os | https | up ca | python | ffmpeg | gource | graphviz | plantuml | shellcheck | shfmt | shunit |
|
||||||
|:----------------|---|---|------------:|------:|-----------:|------:|------:|-----:|-----:|-------:|
|
|:----------------|---|---|------------:|-------:|-----:|------:|-----------:|------:|-----:|------:|
|
||||||
| Ubuntu Jammy | ☐ | ☐ | 3.10 | u2.42 | u1.2020.2 | u0.8 | 2.1.6 | u3.4 | 0.51 | 4.4.2 |
|
| Ubuntu Jammy | ☐ | ☐ | 3.10 | 4.4.2 | 0.51 | u2.42 | u1.2020.2 | u0.8 | u3.4 | 2.1.6 |
|
||||||
| Debian Bullseye | ☐ | ☐ | 3.9 | 2.42 | 1.2020.2 | 0.7 | 2.1.6 | | 0.51 | 4.3.7 |
|
| Debian Bullseye | ☐ | ☐ | 3.9 | 4.3.7 | 0.51 | 2.42 | 1.2020.2 | 0.7 | | 2.1.6 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Who
|
## Who
|
||||||
|
|
||||||
### By
|
### Author
|
||||||
|
|
||||||
* [Marc Beninca](https://marc.beninca.link)
|
* [Marc Beninca](https://marc.beninca.link)
|
||||||
|
|
||||||
### For
|
|
||||||
|
|
||||||
* People feeling the need to aim for consistency in the CI / CD universe
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Where
|
## Where
|
||||||
|
@ -290,5 +274,7 @@ Handle project workflows in a unified way:
|
||||||
* rpm fusion
|
* rpm fusion
|
||||||
* tex
|
* tex
|
||||||
* translate to french
|
* translate to french
|
||||||
* try to support nix
|
* try to support
|
||||||
|
* guix
|
||||||
|
* nix
|
||||||
* uv
|
* uv
|
||||||
|
|
|
@ -10,12 +10,13 @@ from rwx import fs
|
||||||
from rwx.log import stream as log
|
from rwx.log import stream as log
|
||||||
from rwx.ps import run
|
from rwx.ps import run
|
||||||
|
|
||||||
from spcd import cmd
|
from spcd import act, commands
|
||||||
from spcd.ci import project, projects
|
from spcd.ci import project, projects
|
||||||
from spcd.shell import env
|
from spcd.shell import env
|
||||||
from spcd.util import browse, cat, split, step
|
from spcd.util import browse, cat, split, step
|
||||||
|
|
||||||
COMMANDS_PREFIX = "spcd-"
|
COMMANDS_PREFIX = "spcd-"
|
||||||
|
ENTRY_POINT = "__main__.py"
|
||||||
|
|
||||||
|
|
||||||
def clone_project_branch() -> None:
|
def clone_project_branch() -> None:
|
||||||
|
@ -44,6 +45,45 @@ def clone_project_branch() -> None:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def install_actions() -> None:
|
||||||
|
"""Make actions usable in workflows."""
|
||||||
|
step("Install actions")
|
||||||
|
name = "action.yaml"
|
||||||
|
root = project.root / "act"
|
||||||
|
vpy = Path(env.SPCD_PYTHON_VENV_BINARIES) / "python"
|
||||||
|
for action in ("action", "synchronize"):
|
||||||
|
log.info(action)
|
||||||
|
directory = root / action
|
||||||
|
fs.make_directory(directory)
|
||||||
|
match action:
|
||||||
|
case "action":
|
||||||
|
inputs = """\
|
||||||
|
arg_1:
|
||||||
|
required: true
|
||||||
|
arg_2:
|
||||||
|
required: true
|
||||||
|
arg_3:
|
||||||
|
required: true
|
||||||
|
arg_4:
|
||||||
|
default: '"placeholder"'
|
||||||
|
"""
|
||||||
|
case "synchronize":
|
||||||
|
inputs = """\
|
||||||
|
source:
|
||||||
|
default: out
|
||||||
|
required: false
|
||||||
|
"""
|
||||||
|
yaml = f"""\
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- run: {vpy} -m spcd {action}
|
||||||
|
inputs:
|
||||||
|
{inputs}"""
|
||||||
|
fs.write(directory / name, yaml)
|
||||||
|
cat(directory / name)
|
||||||
|
|
||||||
|
|
||||||
def install_commands(path: Path) -> None:
|
def install_commands(path: Path) -> None:
|
||||||
"""Make commands callable in the operating system.
|
"""Make commands callable in the operating system.
|
||||||
|
|
||||||
|
@ -52,12 +92,12 @@ def install_commands(path: Path) -> None:
|
||||||
"""
|
"""
|
||||||
step("Install commands")
|
step("Install commands")
|
||||||
user = Path("/usr/local/bin")
|
user = Path("/usr/local/bin")
|
||||||
for command in [
|
for command in (
|
||||||
"browse-workspace",
|
"browse-workspace",
|
||||||
"build-project",
|
"build-project",
|
||||||
"check-project",
|
"check-project",
|
||||||
"synchronize",
|
"synchronize",
|
||||||
]:
|
):
|
||||||
log.info(command)
|
log.info(command)
|
||||||
(user / f"{COMMANDS_PREFIX}{command}").symlink_to(path)
|
(user / f"{COMMANDS_PREFIX}{command}").symlink_to(path)
|
||||||
|
|
||||||
|
@ -108,15 +148,20 @@ def main(main_file: Path) -> None:
|
||||||
if env.SPCD_PYTHON_VENV_BINARIES not in paths:
|
if env.SPCD_PYTHON_VENV_BINARIES not in paths:
|
||||||
environ["PATH"] = pathsep.join([env.SPCD_PYTHON_VENV_BINARIES, *paths])
|
environ["PATH"] = pathsep.join([env.SPCD_PYTHON_VENV_BINARIES, *paths])
|
||||||
path, *arguments = sys.argv
|
path, *arguments = sys.argv
|
||||||
name = Path(path).name
|
if (name := Path(path).name) == ENTRY_POINT:
|
||||||
if name == "__main__.py":
|
if arguments:
|
||||||
|
name, *arguments = arguments
|
||||||
|
f = getattr(act, name)
|
||||||
|
f(*arguments)
|
||||||
|
else:
|
||||||
list_environment_variables()
|
list_environment_variables()
|
||||||
clone_project_branch()
|
clone_project_branch()
|
||||||
set_ssh()
|
set_ssh()
|
||||||
|
install_actions()
|
||||||
install_commands(main_file)
|
install_commands(main_file)
|
||||||
install_python_packages()
|
install_python_packages()
|
||||||
else:
|
else:
|
||||||
f = getattr(cmd, name.replace("-", "_"))
|
f = getattr(commands, name.replace("-", "_"))
|
||||||
f(*arguments)
|
f(*arguments)
|
||||||
|
|
||||||
|
|
||||||
|
|
62
spcd/act.py
Normal file
62
spcd/act.py
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
"""Actions available for workflows."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
from ast import literal_eval
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from rwx import ps
|
||||||
|
from rwx.log import stream as log
|
||||||
|
|
||||||
|
from spcd.ci import project, projects
|
||||||
|
from spcd.shell import env
|
||||||
|
|
||||||
|
PREFIX = "INPUT_"
|
||||||
|
|
||||||
|
|
||||||
|
def action() -> None:
|
||||||
|
"""Display action inputs."""
|
||||||
|
for variable, value in parse_inputs().items():
|
||||||
|
log.info("%s = %s", variable, value)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_inputs() -> dict[str, object]:
|
||||||
|
"""Parse inputs as a dictionary.
|
||||||
|
|
||||||
|
:return: name & value pairs
|
||||||
|
:rtype: dict[str, object]
|
||||||
|
"""
|
||||||
|
inputs = {}
|
||||||
|
for variable, value in sorted(projects.environment.items()):
|
||||||
|
if variable.startswith(PREFIX):
|
||||||
|
name = variable.removeprefix(PREFIX).lower()
|
||||||
|
inputs[name] = literal_eval(value)
|
||||||
|
return inputs
|
||||||
|
|
||||||
|
|
||||||
|
def synchronize(source: str | None = None, target: str | None = None) -> None:
|
||||||
|
"""Synchronize output towards a target.
|
||||||
|
|
||||||
|
:param source: where to deploy from
|
||||||
|
:type source: str | None
|
||||||
|
:param target: where to deploy to
|
||||||
|
:type target: str | None
|
||||||
|
"""
|
||||||
|
if not target:
|
||||||
|
user = "cd"
|
||||||
|
host = env.SPCD_PROJECT_PATH
|
||||||
|
root = (
|
||||||
|
Path(os.sep) / user / projects.group / project.name / project.branch
|
||||||
|
)
|
||||||
|
target = f"{user}@{host}:{root}"
|
||||||
|
if not source:
|
||||||
|
source = "out"
|
||||||
|
ps.run(
|
||||||
|
"rsync",
|
||||||
|
"--archive",
|
||||||
|
"--delete-before",
|
||||||
|
"--verbose",
|
||||||
|
f"{source}/",
|
||||||
|
f"{target}/",
|
||||||
|
)
|
|
@ -1,5 +1,3 @@
|
||||||
#! /usr/bin/env sh
|
|
||||||
|
|
||||||
# ╭───────────────╮
|
# ╭───────────────╮
|
||||||
# │ __ = internal │
|
# │ __ = internal │
|
||||||
# ╰───────────────╯
|
# ╰───────────────╯
|
||||||
|
@ -386,6 +384,7 @@ spcd_e_default() {
|
||||||
|
|
||||||
[ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2"
|
[ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2"
|
||||||
|
|
||||||
|
[ -n "${SPCD_REF_ARCHIVE}" ] || SPCD_REF_ARCHIVE="old"
|
||||||
[ -n "${SPCD_REF_FEATURE}" ] || SPCD_REF_FEATURE="f"
|
[ -n "${SPCD_REF_FEATURE}" ] || SPCD_REF_FEATURE="f"
|
||||||
[ -n "${SPCD_REF_RELEASE}" ] || SPCD_REF_RELEASE="main"
|
[ -n "${SPCD_REF_RELEASE}" ] || SPCD_REF_RELEASE="main"
|
||||||
[ -n "${SPCD_REF_STAGING}" ] || SPCD_REF_STAGING="dev"
|
[ -n "${SPCD_REF_STAGING}" ] || SPCD_REF_STAGING="dev"
|
||||||
|
@ -513,6 +512,7 @@ ${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
||||||
fi
|
fi
|
||||||
# check project variables
|
# check project variables
|
||||||
case "${SPCD_PROJECT_BRANCH}" in
|
case "${SPCD_PROJECT_BRANCH}" in
|
||||||
|
"${SPCD_REF_ARCHIVE}" | \
|
||||||
"${SPCD_REF_RELEASE}" | \
|
"${SPCD_REF_RELEASE}" | \
|
||||||
"${SPCD_REF_STAGING}" | \
|
"${SPCD_REF_STAGING}" | \
|
||||||
"${SPCD_REF_FEATURE}") ;;
|
"${SPCD_REF_FEATURE}") ;;
|
||||||
|
@ -796,6 +796,15 @@ spcd_f_pkg() {
|
||||||
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}") ;;
|
"${SPCD_OS_ALMA}" | "${SPCD_OS_ROCKY}") ;;
|
||||||
*) spcd_f_pm_pkg_install "gource" ;;
|
*) spcd_f_pm_pkg_install "gource" ;;
|
||||||
esac
|
esac
|
||||||
|
# gpg
|
||||||
|
spcd_step "GnuPG"
|
||||||
|
case "${SPCD_OS_ID}" in
|
||||||
|
"${SPCD_OS_DEBIAN}")
|
||||||
|
spcd_f_pm_pkg_install "gpg"
|
||||||
|
;;
|
||||||
|
# TODO other operating systems
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
# graphviz
|
# graphviz
|
||||||
spcd_step "GraphViz"
|
spcd_step "GraphViz"
|
||||||
spcd_f_pm_pkg_install "graphviz"
|
spcd_f_pm_pkg_install "graphviz"
|
||||||
|
@ -817,6 +826,9 @@ spcd_f_pkg() {
|
||||||
# plantuml
|
# plantuml
|
||||||
spcd_step "PlantUML"
|
spcd_step "PlantUML"
|
||||||
spcd_f_pm_pkg_install "plantuml"
|
spcd_f_pm_pkg_install "plantuml"
|
||||||
|
# qrencode
|
||||||
|
spcd_step "QRencode"
|
||||||
|
spcd_f_pm_pkg_install "qrencode"
|
||||||
# rsync
|
# rsync
|
||||||
spcd_step "Rsync"
|
spcd_step "Rsync"
|
||||||
spcd_f_pm_pkg_install "rsync"
|
spcd_f_pm_pkg_install "rsync"
|
||||||
|
@ -840,6 +852,20 @@ spcd_f_pkg() {
|
||||||
;;
|
;;
|
||||||
*) spcd_f_pm_pkg_install "shfmt" ;;
|
*) spcd_f_pm_pkg_install "shfmt" ;;
|
||||||
esac
|
esac
|
||||||
|
# tex
|
||||||
|
spcd_step "TeX"
|
||||||
|
case "${SPCD_OS_ID}" in
|
||||||
|
"${SPCD_OS_DEBIAN}")
|
||||||
|
spcd_f_pm_pkg_install "texlive-xetex"
|
||||||
|
spcd_f_pm_pkg_install "texlive-lang-french"
|
||||||
|
spcd_f_pm_pkg_install "texlive-plain-generic"
|
||||||
|
spcd_f_pm_pkg_install "texlive-bibtex-extra"
|
||||||
|
spcd_f_pm_pkg_install "texlive-fonts-recommended"
|
||||||
|
spcd_f_pm_pkg_install "biber"
|
||||||
|
;;
|
||||||
|
# TODO other operating systems
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
spcd_step_out
|
spcd_step_out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1379,6 +1405,7 @@ index-url = ${SPCD_URL_PYTHON}/simple
|
||||||
spcd_step "Activate"
|
spcd_step "Activate"
|
||||||
export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}"
|
export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}"
|
||||||
export VIRTUAL_ENV="${SPCD_PYTHON_VENV}"
|
export VIRTUAL_ENV="${SPCD_PYTHON_VENV}"
|
||||||
|
pip install "PyYAML"
|
||||||
spcd_step_out
|
spcd_step_out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""Commands available for workflows."""
|
"""Commands available for workflows."""
|
||||||
|
|
||||||
import os
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from os import sep
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rwx import ps
|
from rwx import ps
|
||||||
|
@ -17,8 +19,8 @@ def spcd_browse_workspace() -> None:
|
||||||
|
|
||||||
def spcd_build_project() -> None:
|
def spcd_build_project() -> None:
|
||||||
"""Perform the actual building process."""
|
"""Perform the actual building process."""
|
||||||
for extension in ["py", "sh"]:
|
for extension in ("py", "sh"):
|
||||||
path = project.root / f"build.{extension}"
|
path = project.root / f"render.{extension}"
|
||||||
if path.exists():
|
if path.exists():
|
||||||
ps.run(str(path))
|
ps.run(str(path))
|
||||||
break
|
break
|
||||||
|
@ -26,11 +28,25 @@ def spcd_build_project() -> None:
|
||||||
|
|
||||||
def spcd_check_project() -> None:
|
def spcd_check_project() -> None:
|
||||||
"""Check the project for anything wrong."""
|
"""Check the project for anything wrong."""
|
||||||
ps.run("ruff", "check")
|
ps.run(
|
||||||
|
"ruff",
|
||||||
|
"check",
|
||||||
|
("--ignore", "D203,D213"),
|
||||||
|
"--isolated",
|
||||||
|
("--select", "ALL"),
|
||||||
|
)
|
||||||
|
ps.run(
|
||||||
|
"ruff",
|
||||||
|
"format",
|
||||||
|
"--diff",
|
||||||
|
"--isolated",
|
||||||
|
("--line-length", "80"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def spcd_synchronize(
|
def spcd_synchronize(
|
||||||
source: str | None = None, target: str | None = None
|
source: str | None = None,
|
||||||
|
target: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Synchronize output towards a target.
|
"""Synchronize output towards a target.
|
||||||
|
|
||||||
|
@ -42,9 +58,7 @@ def spcd_synchronize(
|
||||||
if not target:
|
if not target:
|
||||||
user = "cd"
|
user = "cd"
|
||||||
host = env.SPCD_PROJECT_PATH
|
host = env.SPCD_PROJECT_PATH
|
||||||
root = (
|
root = Path(sep) / user / projects.group / project.name / project.branch
|
||||||
Path(os.sep) / user / projects.group / project.name / project.branch
|
|
||||||
)
|
|
||||||
target = f"{user}@{host}:{root}"
|
target = f"{user}@{host}:{root}"
|
||||||
if not source:
|
if not source:
|
||||||
source = "out"
|
source = "out"
|
||||||
|
@ -53,6 +67,6 @@ def spcd_synchronize(
|
||||||
"--archive",
|
"--archive",
|
||||||
"--delete-before",
|
"--delete-before",
|
||||||
"--verbose",
|
"--verbose",
|
||||||
f"{source}/",
|
f"{source}{sep}",
|
||||||
f"{target}/",
|
f"{target}{sep}",
|
||||||
)
|
)
|
Loading…
Add table
Add a link
Reference in a new issue