Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
328 changes: 117 additions & 211 deletions .github/workflows/daily.yml

Large diffs are not rendered by default.

77 changes: 45 additions & 32 deletions .github/workflows/healthcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,29 @@ jobs:

# Use pipe because of this bug
# https://github.com/mikefarah/yq/issues/2454
matrix=$(yq -o=json labnet.yaml | jq '
. as $root |
$root.labs as $labs |
$root.devices as $devices |
$labs
| to_entries
| map(
.key as $lab |
.value.devices
| map(
select($devices[.] != null and $devices[.].snapshots_only != true) |
{
"device": .,
"proxy": $labs[$lab].proxy,
"target": $devices[.].target,
"firmware": $devices[.].firmware,
"maintainers": $labs[$lab].maintainers,
"snapshots_only": ($devices[.].snapshots_only // false)
}
)
devices_meta=$(
for f in targets/*.yaml; do
head -1 "$f" | grep -q '^openwrt:' || continue
device=$(basename "$f" .yaml)
so=$(yq -r '.openwrt.snapshots_only // false' "$f")
jq -n --arg d "$device" --argjson so "$so" '{($d): {snapshots_only: $so}}'
done | jq -s 'add'
)

matrix=$(yq -o=json labnet.yaml | jq --argjson devices "$devices_meta" '
.labs as $labs |
($labs | to_entries) | map(
.key as $lab |
$labs[$lab].devices | map(
select($devices[.] != null and $devices[.].snapshots_only != true) |
{
"device": .,
"proxy": $labs[$lab].proxy,
"maintainers": $labs[$lab].maintainers,
"snapshots_only": $devices[.].snapshots_only
}
)
| flatten
) | flatten
')
echo "matrix=$(echo "$matrix" | jq -c '.')" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -99,26 +100,38 @@ jobs:

- name: Set environment
env:
target: ${{ matrix.target }}
DEVICE: ${{ matrix.device }}
run: |
# workaround until 24.10.x is fixed on tplink_tl-wr1043nd-v3
if [ "${{ matrix.device }}" = "tplink_tl-wr1043nd-v3" ]; then
if [ "$DEVICE" = "tplink_tl-wr1043nd-v3" ]; then
export RELEASE=23.05.5
echo "RELEASE=${RELEASE}" >> $GITHUB_ENV
fi

export firmware=openwrt-${RELEASE}-${{ matrix.target }}-${{ matrix.device }}-${{ matrix.firmware }}
export upstream_url="https://mirror-03.infra.openwrt.org/releases/${RELEASE}/targets"
target=$(yq -r '.openwrt.target' targets/$DEVICE.yaml)
profile=$(yq -r '.openwrt.profile' targets/$DEVICE.yaml)
image_type=$(yq -r '.openwrt.image.type // "kernel"' targets/$DEVICE.yaml)
image_fs=$(yq -r '.openwrt.image.filesystem // ""' targets/$DEVICE.yaml)

mkdir -p $GITHUB_WORKSPACE/tftp/${{ matrix.device }}
wget $upstream_url/${target/-/\/}/$firmware \
--output-document $GITHUB_WORKSPACE/tftp/${{ matrix.device }}/$firmware
(cd $GITHUB_WORKSPACE/tftp/ && gzip -d ${{ matrix.device }}/$firmware) || true
upstream_url="https://mirror-03.infra.openwrt.org/releases/${RELEASE}/targets"
profiles_json=$(curl -sf "$upstream_url/${target/-/\/}/profiles.json")

FIRMWARE_VERSION=$(curl $upstream_url/${target/-/\/}/version.buildinfo)
echo "FIRMWARE_VERSION=$FIRMWARE_VERSION" >> $GITHUB_ENV
if [ -n "$image_fs" ]; then
firmware_name=$(echo "$profiles_json" | jq -r --arg p "$profile" --arg t "$image_type" --arg fs "$image_fs" \
'.profiles[$p].images[]? | select(.type == $t and .filesystem == $fs) | .name' | head -n1)
else
firmware_name=$(echo "$profiles_json" | jq -r --arg p "$profile" --arg t "$image_type" \
'.profiles[$p].images[]? | select(.type == $t) | .name' | head -n1)
fi

echo "LG_IMAGE=$GITHUB_WORKSPACE/tftp/${{ matrix.device }}/${firmware/.gz/}" >> $GITHUB_ENV
mkdir -p $GITHUB_WORKSPACE/tftp/$DEVICE
wget -q "$upstream_url/${target/-/\/}/$firmware_name" \
--output-document "$GITHUB_WORKSPACE/tftp/$DEVICE/$firmware_name"
(cd $GITHUB_WORKSPACE/tftp/ && gzip -df $DEVICE/$firmware_name) || true

FIRMWARE_VERSION=$(echo "$profiles_json" | jq -r '.version_code')
echo "FIRMWARE_VERSION=$FIRMWARE_VERSION" >> $GITHUB_ENV
echo "LG_IMAGE=$GITHUB_WORKSPACE/tftp/$DEVICE/${firmware_name/.gz/}" >> $GITHUB_ENV
echo "LG_PROXY=${{ matrix.proxy }}" >> $GITHUB_ENV

- name: Install dependencies
Expand Down
49 changes: 25 additions & 24 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ env:
PYTHONUNBUFFERED: "1"
PYTEST_ADDOPTS: "--color=yes"
LG_CONSOLE: "internal"
RELEASE: "24.10.2"

concurrency:
group: pr-${{ github.workflow }}-${{ github.ref }}
Expand All @@ -22,15 +21,10 @@ jobs:
matrix:
include:
- target: malta-be
firmware: openwrt-${RELEASE}-malta-be-vmlinux-initramfs.elf
dependency: qemu-system-mips

- target: x86-64
firmware: openwrt-${RELEASE}-x86-64-generic-squashfs-combined.img.gz
dependency: qemu-system-x86

- target: armsr-armv8
firmware: openwrt-${RELEASE}-armsr-armv8-generic-initramfs-kernel.bin
dependency: qemu-system-aarch64

steps:
Expand All @@ -40,41 +34,48 @@ jobs:
- name: Setup environment
run: |
sudo apt-get update
sudo apt-get -y install \
nmap \
${{ matrix.dependency }}

# workaround until ARMSR is fixed
if [ "${{ matrix.target }}" = "armsr-armv8" ]; then
export RELEASE=23.05.5
echo "RELEASE=${RELEASE}" >> $GITHUB_ENV
fi
sudo apt-get -y install nmap ${{ matrix.dependency }}

RELEASE=$(curl -s https://downloads.openwrt.org/.versions.json | jq -r '.stable_version')
echo "RELEASE=$RELEASE" >> $GITHUB_ENV
echo "LG_ENV=targets/qemu_${{ matrix.target }}.yaml" >> $GITHUB_ENV
echo "UPSTREAM_URL=https://mirror-03.infra.openwrt.org/releases/${RELEASE}/targets" >> $GITHUB_ENV

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Download test firmware
env:
target: ${{ matrix.target }}
run: |
wget $UPSTREAM_URL/${target/-/\/}/${{ matrix.firmware }} \
--output-document ${{ matrix.firmware }}
FIRMWARE_VERSION=$(curl $UPSTREAM_URL/${target/-/\/}/version.buildinfo)
target=$(yq -r '.openwrt.target' targets/qemu_${{ matrix.target }}.yaml)
profile=$(yq -r '.openwrt.profile' targets/qemu_${{ matrix.target }}.yaml)
image_type=$(yq -r '.openwrt.image.type // "kernel"' targets/qemu_${{ matrix.target }}.yaml)
image_fs=$(yq -r '.openwrt.image.filesystem // ""' targets/qemu_${{ matrix.target }}.yaml)

upstream_url="https://mirror-03.infra.openwrt.org/releases/${RELEASE}/targets"
profiles_json=$(curl -sf "$upstream_url/${target/-/\/}/profiles.json")

if [ -n "$image_fs" ]; then
firmware_name=$(echo "$profiles_json" | jq -r --arg p "$profile" --arg t "$image_type" --arg fs "$image_fs" \
'.profiles[$p].images[]? | select(.type == $t and .filesystem == $fs) | .name' | head -n1)
else
firmware_name=$(echo "$profiles_json" | jq -r --arg p "$profile" --arg t "$image_type" \
'.profiles[$p].images[]? | select(.type == $t) | .name' | head -n1)
fi

wget -q "$upstream_url/${target/-/\/}/$firmware_name" --output-document "$firmware_name"
FIRMWARE_VERSION=$(echo "$profiles_json" | jq -r '.version_code')
echo "FIRMWARE_VERSION=$FIRMWARE_VERSION" >> $GITHUB_ENV
echo "FIRMWARE_FILE=$firmware_name" >> $GITHUB_ENV

- name: Run test
run: |
gunzip ${{ matrix.firmware }} || true
firmware=${{ matrix.firmware }}
gunzip $FIRMWARE_FILE || true
firmware=${FIRMWARE_FILE/.gz/}

uv run pytest tests/ \
--lg-log \
--lg-colored-steps \
--log-cli-level=CONSOLE \
--firmware $GITHUB_WORKSPACE/${firmware/.gz/}
--firmware $GITHUB_WORKSPACE/$firmware

- name: Upload console logs
uses: actions/upload-artifact@v7
Expand Down
16 changes: 10 additions & 6 deletions docs/sharing-target-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ When a lab has multiple physical devices of the same model (e.g., three Belkin R
If this is your situation, you can use the `device_instances` field in `labnet.yaml` to define multiple physical instances sharing a single target file:

```yaml
devices:
linksys_e8450:
name: Linksys E8450 / Belkin RT3200
target: mediatek-mt7622
firmware: initramfs-kernel.bin

labs:
labgrid-example:
proxy: labgrid-example
Expand All @@ -26,6 +20,16 @@ labs:
- router_3
```

Device metadata (name, OpenWrt target, profile, image selection) lives in the labgrid target file (`targets/linksys_e8450.yaml`):

```yaml
openwrt:
name: Linksys E8450 / Belkin RT3200
target: mediatek-mt7622
profile: linksys_e8450
# image.type defaults to "kernel"; override only for factory / combined images
```

This will create three different labgrid places from the same configuration file.
- `labgrid-example-router_1` → `targets/linksys_e8450.yaml`
- `labgrid-example-router_2` → `targets/linksys_e8450.yaml`
Expand Down
Loading
Loading