commit: ba892246415609db46b2520187d4c2fae8578de8
parent 7d50a224c66ced52e15693eaa669d649868b9565
Author: fosslinux <fosslinux@aussies.space>
Date: Mon, 13 Jan 2025 19:47:27 +1100
Modify GH actions to support mirror
Diffstat:
2 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/.github/workflows/bwrap.yml b/.github/workflows/bwrap.yml
@@ -32,20 +32,24 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
- distfiles
+ mirror
+ mirror-state
key: cache-${{ hashFiles('steps/*/sources') }}
+ restore-keys: |
+ cache-
- name: Get sources
if: steps.cache.outputs.cache-hit != 'true'
- run: ./download-distfiles.sh
+ run: mkdir -p mirror mirror-state && ./mirror.sh mirror mirror-state
- name: Cache sources
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
- distfiles
+ mirror
+ mirror-state
key: cache-${{ hashFiles('steps/*/sources') }}
- name: Run bootstrap
- run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass1
+ run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass1 --mirror file://${PWD}/mirror
- name: Archive created packages
if: failure() # archive failed builds progress
uses: actions/upload-artifact@v4
@@ -87,18 +91,12 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
- distfiles
- key: cache-${{ hashFiles('steps/*/sources') }}
- - name: Get sources
- if: steps.cache.outputs.cache-hit != 'true'
- run: ./download-distfiles.sh
- - name: Cache sources
- if: steps.cache.outputs.cache-hit != 'true'
- uses: actions/cache/save@v4
- with:
- path: |
- distfiles
+ mirror
+ mirror-state
key: cache-${{ hashFiles('steps/*/sources') }}
+ fail-on-cache-miss: true
+ - name: Copy distfiles
+ run: ./download-distfiles.sh file:///${PWD}/mirror
- name: Run bootstrap
run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass2
- name: Archive created packages
@@ -142,20 +140,14 @@ jobs:
uses: actions/cache/restore@v4
with:
path: |
- distfiles
- key: cache-${{ hashFiles('steps/*/sources') }}
- - name: Get sources
- if: steps.cache.outputs.cache-hit != 'true'
- run: ./download-distfiles.sh
- - name: Cache sources
- if: steps.cache.outputs.cache-hit != 'true'
- uses: actions/cache/save@v4
- with:
- path: |
- distfiles
+ mirror
+ mirror-state
key: cache-${{ hashFiles('steps/*/sources') }}
+ fail-on-cache-miss: true
+ - name: Copy distfiles
+ run: ./download-distfiles.sh file:///${PWD}/mirror
- name: Run bootstrap
- run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass3
+ run: ./rootfs.py --bwrap --external-sources --build-kernels --cores 2 --internal-ci pass3 --mirror file://${PWD}/mirror
- name: Archive created packages
if: always() # archive both failed and successful builds
uses: actions/upload-artifact@v4
diff --git a/lib/simple_mirror.py b/lib/simple_mirror.py
@@ -1,13 +1,22 @@
+#!/usr/bin/env python3
+"""
+This creates a simple "mirror" from a directory
+"""
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2025 fosslinux <fosslinux@aussies.space>
+
import http.server
import socketserver
class SimpleMirror(socketserver.TCPServer):
+ """Simple HTTP mirror from a directory"""
def __init__(self, directory: str):
self.directory = directory
super().__init__(("localhost", 0), self._handler)
@property
def port(self):
+ """Port the HTTP server of the mirror is running on"""
return self.server_address[1]
def _handler(self, *args, **kwargs):