Skip to content

Commit 7803f6b

Browse files
authored
Merge pull request #1092 from kernelkit/github-wokflow-impovments
GitHub wokflow impovments
2 parents 5c1bcba + 8a1747d commit 7803f6b

File tree

10 files changed

+124
-20
lines changed

10 files changed

+124
-20
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
build:
5656
name: Build ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }}
5757
runs-on: [ self-hosted, latest ]
58+
env:
59+
PARALLEL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.parallel == 'true' || github.event_name != 'workflow_dispatch' && inputs.parallel == true }}
5860
strategy:
5961
fail-fast: false
6062
outputs:
@@ -126,7 +128,7 @@ jobs:
126128
id: parallel
127129
run: |
128130
129-
if [ "${{ ((github.event.inputs.parallel == 'true' && github.event_name == 'workflow_dispatch') || (github.ref_name != 'main' && github.event_name != 'workflow_dispatch')) }}" == "true" ]; then
131+
if [ "$PARALLEL" == "true" ]; then
130132
echo "BR2_PER_PACKAGE_DIRECTORIES=y" >> output/.config
131133
MAKE="make -j$((`getconf _NPROCESSORS_ONLN` / 2 + 2))"
132134
echo "Building in parallel with -j$((`getconf _NPROCESSORS_ONLN` / 2 + 2))"
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Generic X86 GitHub Build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
if: github.repository != 'kernelkit/infix'
9+
name: Infix x86_64
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Install build dependencies
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get install -y \
17+
bc binutils build-essential bzip2 cpio \
18+
diffutils file findutils git gzip \
19+
libncurses-dev libssl-dev perl patch \
20+
python3 rsync sed tar unzip wget \
21+
autopoint bison flex autoconf automake \
22+
mtools
23+
24+
- name: Checkout infix repo
25+
uses: actions/checkout@v4
26+
with:
27+
repository: ${{ github.repository }}
28+
ref: ${{ github.ref }}
29+
fetch-depth: 0
30+
submodules: recursive
31+
32+
- name: Set Build Variables
33+
id: vars
34+
run: |
35+
echo "INFIX_BUILD_ID=${{ github.run_id }}" >> $GITHUB_OUTPUT
36+
echo "dir=Infix-x86_64" >> $GITHUB_OUTPUT
37+
echo "tgz=Infix-x86_64.tar.gz" >> $GITHUB_OUTPUT
38+
echo "flv=_minimal" >> $GITHUB_OUTPUT
39+
40+
- name: Configure x86_64_minimal
41+
run: |
42+
make x86_64_minimal_defconfig
43+
44+
- name: Unit Test x86_64
45+
run: |
46+
make test-unit
47+
48+
- name: Build x86_64_minimal
49+
run: |
50+
make
51+
52+
- name: Check SBOM
53+
run: |
54+
make legal-info
55+
56+
- name: Report Build Size
57+
run: |
58+
du -sh .
59+
du -sh output
60+
du -sh dl || true
61+
ls -l output/images/
62+
63+
- name: Prepare Artifact
64+
run: |
65+
cd output/
66+
mv images Infix-x86_64
67+
ln -s Infix-x86_64 images
68+
tar cfz Infix-x86_64.tar.gz Infix-x86_64
69+
70+
- uses: actions/upload-artifact@v4
71+
with:
72+
path: output/Infix-x86_64.tar.gz
73+
name: artifact-x86_64
74+

.github/workflows/trigger.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Self Trigger
1+
name: Kernelkit Trigger
22

33
on:
44
pull_request:
@@ -11,27 +11,31 @@ on:
1111

1212
jobs:
1313
build-x86_64:
14+
if: startsWith(github.repository, 'kernelkit/')
1415
uses: ./.github/workflows/build.yml
1516
with:
1617
target: "x86_64"
1718
name: "infix"
1819
flavor: "_minimal"
1920

2021
build-aarch64:
22+
if: startsWith(github.repository, 'kernelkit/')
2123
uses: ./.github/workflows/build.yml
2224
with:
2325
target: "aarch64"
2426
name: "infix"
2527
flavor: "_minimal"
2628

2729
test-run-x86_64:
30+
if: startsWith(github.repository, 'kernelkit/')
2831
needs: build-x86_64
2932
uses: ./.github/workflows/test.yml
3033
with:
3134
target: "x86_64"
3235
name: "infix"
3336

3437
test-publish-x86_64:
38+
if: startsWith(github.repository, 'kernelkit/')
3539
needs: test-run-x86_64
3640
uses: ./.github/workflows/publish.yml
3741

src/statd/python/yanger/host.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ def read(self, path):
116116

117117
return None
118118

119+
def exists(self, path: str) -> bool:
120+
try:
121+
return os.path.exists(path)
122+
except OSError:
123+
return False
119124

120125
class Remotehost(Localhost):
121126
def __init__(self, prefix, capdir):
@@ -159,6 +164,18 @@ def run(self, cmd, default=None, log=True):
159164

160165
return out
161166

167+
def exists(self, path: str) -> bool:
168+
if not self._run(("ls", path), default="", log=False):
169+
return False
170+
171+
if self.capdir:
172+
dirname = os.path.join(self.capdir, "rootfs", os.path.dirname(path[1:]))
173+
filname = os.path.join(self.capdir, "rootfs", path[1:])
174+
os.makedirs(dirname, exist_ok=True)
175+
open(filname, "w", encoding='utf-8').close() # Create empty file
176+
177+
return True
178+
162179
def read(self, path):
163180
out = self._run(("cat", path), default="", log=False)
164181

@@ -199,6 +216,13 @@ def run(self, cmd, default=None, log=True):
199216
common.LOG.error(f"No recording found for run \"{path}\"")
200217
raise
201218

219+
def exists(self, path: str) -> bool:
220+
path = os.path.join(self.replaydir, "rootfs", path[1:])
221+
try:
222+
return os.path.exists(path)
223+
except OSError:
224+
return False
225+
202226
def read(self, path):
203227
path = os.path.join(self.replaydir, "rootfs", path[1:])
204228
try:

src/statd/python/yanger/ietf_hardware.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,16 @@ def usb_port_components(systemjson):
6161

6262
path = usb_port["path"]
6363
if os.path.basename(path) == "authorized_default":
64-
# TODO: Untestable. Should be done via the host API
65-
if os.path.exists(path):
66-
with open(path, "r") as f:
67-
names.append(usb_port["name"])
68-
data = int(f.readline().strip())
69-
enabled = "unlocked" if data == 1 else "locked"
70-
port["state"] = {}
71-
port["state"]["admin-state"] = enabled
72-
port["name"] = usb_port["name"]
73-
port["class"] = "infix-hardware:usb"
74-
port["state"]["oper-state"] = "enabled"
75-
ports.append(port)
64+
if HOST.exists(path):
65+
names.append(usb_port["name"])
66+
data = int(HOST.read(path))
67+
enabled = "unlocked" if data == 1 else "locked"
68+
port["state"] = {}
69+
port["state"]["admin-state"] = enabled
70+
port["name"] = usb_port["name"]
71+
port["class"] = "infix-hardware:usb"
72+
port["state"]["oper-state"] = "enabled"
73+
ports.append(port)
7674

7775
return ports
7876

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
USB PORTS 
22
NAME STATE 
3-
USB unlocked
4-
USB2 unlocked
3+
USB locked
4+
USB2 locked

test/case/statd/system/ietf-hardware.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
},
88
{
99
"state": {
10-
"admin-state": "unlocked",
10+
"admin-state": "locked",
1111
"oper-state": "enabled"
1212
},
1313
"name": "USB",
1414
"class": "infix-hardware:usb"
1515
},
1616
{
1717
"state": {
18-
"admin-state": "unlocked",
18+
"admin-state": "locked",
1919
"oper-state": "enabled"
2020
},
2121
"name": "USB2",

test/case/statd/system/operational.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
"class": "infix-hardware:usb",
1010
"name": "USB",
1111
"state": {
12-
"admin-state": "unlocked",
12+
"admin-state": "locked",
1313
"oper-state": "enabled"
1414
}
1515
},
1616
{
1717
"class": "infix-hardware:usb",
1818
"name": "USB2",
1919
"state": {
20-
"admin-state": "unlocked",
20+
"admin-state": "locked",
2121
"oper-state": "enabled"
2222
}
2323
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

0 commit comments

Comments
 (0)