Skip to content

Commit ba89224

Browse files
committed
Modify GH actions to support mirror
1 parent 7d50a22 commit ba89224

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

.github/workflows/bwrap.yml

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,24 @@ jobs:
3232
uses: actions/cache/restore@v4
3333
with:
3434
path: |
35-
distfiles
35+
mirror
36+
mirror-state
3637
key: cache-${{ hashFiles('steps/*/sources') }}
38+
restore-keys: |
39+
cache-
3740
- name: Get sources
3841
if: steps.cache.outputs.cache-hit != 'true'
39-
run: ./download-distfiles.sh
42+
run: mkdir -p mirror mirror-state && ./mirror.sh mirror mirror-state
4043
- name: Cache sources
4144
if: steps.cache.outputs.cache-hit != 'true'
4245
uses: actions/cache/save@v4
4346
with:
4447
path: |
45-
distfiles
48+
mirror
49+
mirror-state
4650
key: cache-${{ hashFiles('steps/*/sources') }}
4751
- name: Run bootstrap
48-
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass1
52+
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass1 --mirror file://${PWD}/mirror
4953
- name: Archive created packages
5054
if: failure() # archive failed builds progress
5155
uses: actions/upload-artifact@v4
@@ -87,18 +91,12 @@ jobs:
8791
uses: actions/cache/restore@v4
8892
with:
8993
path: |
90-
distfiles
91-
key: cache-${{ hashFiles('steps/*/sources') }}
92-
- name: Get sources
93-
if: steps.cache.outputs.cache-hit != 'true'
94-
run: ./download-distfiles.sh
95-
- name: Cache sources
96-
if: steps.cache.outputs.cache-hit != 'true'
97-
uses: actions/cache/save@v4
98-
with:
99-
path: |
100-
distfiles
94+
mirror
95+
mirror-state
10196
key: cache-${{ hashFiles('steps/*/sources') }}
97+
fail-on-cache-miss: true
98+
- name: Copy distfiles
99+
run: ./download-distfiles.sh file:///${PWD}/mirror
102100
- name: Run bootstrap
103101
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass2
104102
- name: Archive created packages
@@ -142,20 +140,14 @@ jobs:
142140
uses: actions/cache/restore@v4
143141
with:
144142
path: |
145-
distfiles
146-
key: cache-${{ hashFiles('steps/*/sources') }}
147-
- name: Get sources
148-
if: steps.cache.outputs.cache-hit != 'true'
149-
run: ./download-distfiles.sh
150-
- name: Cache sources
151-
if: steps.cache.outputs.cache-hit != 'true'
152-
uses: actions/cache/save@v4
153-
with:
154-
path: |
155-
distfiles
143+
mirror
144+
mirror-state
156145
key: cache-${{ hashFiles('steps/*/sources') }}
146+
fail-on-cache-miss: true
147+
- name: Copy distfiles
148+
run: ./download-distfiles.sh file:///${PWD}/mirror
157149
- name: Run bootstrap
158-
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass3
150+
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass3 --mirror file://${PWD}/mirror
159151
- name: Archive created packages
160152
if: always() # archive both failed and successful builds
161153
uses: actions/upload-artifact@v4

lib/simple_mirror.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
#!/usr/bin/env python3
2+
"""
3+
This creates a simple "mirror" from a directory
4+
"""
5+
# SPDX-License-Identifier: GPL-3.0-or-later
6+
# SPDX-FileCopyrightText: 2025 fosslinux <[email protected]>
7+
18
import http.server
29
import socketserver
310

411
class SimpleMirror(socketserver.TCPServer):
12+
"""Simple HTTP mirror from a directory"""
513
def __init__(self, directory: str):
614
self.directory = directory
715
super().__init__(("localhost", 0), self._handler)
816

917
@property
1018
def port(self):
19+
"""Port the HTTP server of the mirror is running on"""
1120
return self.server_address[1]
1221

1322
def _handler(self, *args, **kwargs):

0 commit comments

Comments
 (0)