Skip to content

Commit a8f7fc1

Browse files
committed
Modify GH actions to support mirror
1 parent 61be6d4 commit a8f7fc1

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

.github/workflows/bwrap.yml

Lines changed: 15 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,10 @@ 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
10195
key: cache-${{ hashFiles('steps/*/sources') }}
96+
- name: Copy distfiles
97+
run: ./download-distfiles.sh file:///${PWD}/mirror
10298
- name: Run bootstrap
10399
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass2
104100
- name: Archive created packages
@@ -142,20 +138,12 @@ jobs:
142138
uses: actions/cache/restore@v4
143139
with:
144140
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
141+
mirror
156142
key: cache-${{ hashFiles('steps/*/sources') }}
143+
- name: Copy distfiles
144+
run: ./download-distfiles.sh file:///${PWD}/mirror
157145
- name: Run bootstrap
158-
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass3
146+
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass3 --mirror file://${PWD}/mirror
159147
- name: Archive created packages
160148
if: always() # archive both failed and successful builds
161149
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__(("127.0.0.1", 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)