1
0

ci?
Some checks failed
CI / Typos (push) Successful in 12s
CI / Clippy (push) Failing after 31s
CI / Build (push) Failing after 1m8s

This commit is contained in:
Mark 2025-02-25 19:37:02 -08:00
parent 81fcd2a6e2
commit 073c42b2eb
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
5 changed files with 120 additions and 7 deletions

View File

@ -16,7 +16,7 @@ jobs:
- name: Check typos
uses: crate-ci/typos@master
with:
config: ./typos.toml
config: ./tools/typos.toml
clippy:
name: "Clippy"
@ -50,7 +50,33 @@ jobs:
sudo apt update
DEBIAN_FRONTEND=noninteractive \
sudo apt install --yes \
rustup nasm
rustup nasm python3-requests
- name: Build
run: make
# Upload build output
- name: "Save output"
uses: actions/upload-artifact@v3
with:
name: "Build output"
path: "build/*"
retention-days: 7
- name: "Publish package (hash)"
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
PUBLISH_USER="${{ secrets.PUBLISH_USER }}" \
PUBLISH_KEY="${{ secrets.PUBLISH_KEY }}" \
VERSION="${{ github.sha }}" \
PACKAGE="${{ vars.PACKAGE }}" \
python tools/scripts/publish.py
- name: "Publish package (latest)"
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
PUBLISH_USER="${{ secrets.PUBLISH_USER }}" \
PUBLISH_KEY="${{ secrets.PUBLISH_KEY }}" \
VERSION="latest" \
PACKAGE="${{ vars.PACKAGE }}" \
python tools/scripts/publish.py

View File

@ -84,7 +84,7 @@ pub unsafe trait HandlerFuncType {
unsafe impl HandlerFuncType for HandlerFunc {
#[inline]
fn to_virt_addr(self) -> VirtAddr {
#[allow(clippy::fn_to_numeric_cast_with_truncation)]
#[expect(clippy::fn_to_numeric_cast_with_truncation)]
VirtAddr::new(self as u32)
}
}
@ -92,7 +92,7 @@ unsafe impl HandlerFuncType for HandlerFunc {
unsafe impl HandlerFuncType for HandlerFuncWithErrCode {
#[inline]
fn to_virt_addr(self) -> VirtAddr {
#[allow(clippy::fn_to_numeric_cast_with_truncation)]
#[expect(clippy::fn_to_numeric_cast_with_truncation)]
VirtAddr::new(self as u32)
}
}
@ -100,7 +100,7 @@ unsafe impl HandlerFuncType for HandlerFuncWithErrCode {
unsafe impl HandlerFuncType for DivergingHandlerFunc {
#[inline]
fn to_virt_addr(self) -> VirtAddr {
#[allow(clippy::fn_to_numeric_cast_with_truncation)]
#[expect(clippy::fn_to_numeric_cast_with_truncation)]
VirtAddr::new(self as u32)
}
}
@ -108,7 +108,7 @@ unsafe impl HandlerFuncType for DivergingHandlerFunc {
unsafe impl HandlerFuncType for DivergingHandlerFuncWithErrCode {
#[inline]
fn to_virt_addr(self) -> VirtAddr {
#[allow(clippy::fn_to_numeric_cast_with_truncation)]
#[expect(clippy::fn_to_numeric_cast_with_truncation)]
VirtAddr::new(self as u32)
}
}
@ -116,7 +116,7 @@ unsafe impl HandlerFuncType for DivergingHandlerFuncWithErrCode {
unsafe impl HandlerFuncType for PageFaultHandlerFunc {
#[inline]
fn to_virt_addr(self) -> VirtAddr {
#[allow(clippy::fn_to_numeric_cast_with_truncation)]
#[expect(clippy::fn_to_numeric_cast_with_truncation)]
VirtAddr::new(self as u32)
}
}

69
tools/scripts/publish.py Normal file
View File

@ -0,0 +1,69 @@
# Publish the output of `build.py`
# as a Gitea package.
from pathlib import Path
import requests
import os
import re
URL = "https://git.betalupi.com"
USER = os.environ["PUBLISH_USER"]
PACKAGE = os.environ["PACKAGE"]
VERSION = os.environ["VERSION"]
AUTH = requests.auth.HTTPBasicAuth(USER, os.environ["PUBLISH_KEY"])
ROOT: Path = Path(os.getcwd())
SRC_DIR: Path = ROOT / "output"
def log(msg):
print(f"[PUBLISH.PY] {msg}")
log(f"Version is {VERSION}")
log(f"Package is {PACKAGE}")
log(f"Running in {ROOT}")
if not ROOT.is_dir():
log("Root is not a directory, cannot continue")
exit(1)
log(f"Source dir is {SRC_DIR}")
if not SRC_DIR.exists():
log("Source dir doesn't exist, cannot continue")
exit(1)
def del_package():
log(f"Deleting package {PACKAGE}/{VERSION}")
res = requests.delete(
f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}",
auth=AUTH,
)
if res.status_code != 204 and res.status_code != 404:
log(f"Deletion failed with code {res.status_code}")
# Delete if already exists
# (important for the `latest` package)
del_package()
def upload(data, target: str):
target = re.sub("[^A-Za-z0-9_. -]+", "", target)
res = requests.put(
f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}/{target}",
auth=AUTH,
data=data,
)
if res.status_code != 201:
log(f"Upload failed with code {res.status_code}")
del_package() # Do not keep partial package if upload fails
exit(1)
return f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}/{target}"
log("Uploading disk.img")
upload(Path("./build/disk.img").open("rb").read(), "disk.img")

18
tools/scripts/ruff.toml Normal file
View File

@ -0,0 +1,18 @@
exclude = ["venv"]
line-length = 88
indent-width = 4
target-version = "py39"
include = ["scripts/**/*.py"]
[lint]
select = ["E4", "E7", "E9", "F"]
ignore = []
fixable = ["ALL"]
unfixable = []
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[format]
quote-style = "double"
indent-style = "tab"
skip-magic-trailing-comma = false
line-ending = "lf"