Skip to content

Commit

Permalink
Again
Browse files Browse the repository at this point in the history
  • Loading branch information
VexedUXR committed Nov 14, 2024
1 parent 5d8c5ff commit 06d9861
Showing 1 changed file with 124 additions and 32 deletions.
156 changes: 124 additions & 32 deletions .github/workflows/cross-bootstrap-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,146 @@ on:
branches: [ main, 'stable/14', 'stable/13' ]
paths:
- 'sys/**'
- 'stand/**'

- 'bin/**'
- 'sbin/**'
- 'usr.bin/**'
- 'usr.sbin/**'

# XXX What to build here?
- 'Makefile'
- 'Makefile.inc1'

- '**/cross-bootstrap-tools.yml'

- '!**.[1-9]' # Ignore manpages
pull_request:
branches: [ main ]
paths:
- 'sys/**'
- 'stand/**'

- 'bin/**'
- 'sbin/**'
- 'usr.bin/**'
- 'usr.sbin/**'

# XXX What to build here?
- 'Makefile'
- 'Makefile.inc1'

- '**/cross-bootstrap-tools.yml'

- '!**.[1-9]' # Ignore manpages
workflow_dispatch:

permissions:
contents: read

jobs:
modified_files:
name: get modified files
setup:
name: setup
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.changes.outputs.files }}
archs: ${{ steps.match.outputs.archs }}
make_targets: ${{ steps.match.outputs.make_targets }}
steps:
- uses: actions/checkout@v4
- name: get modified files
id: changes
- name: checkout
uses: actions/checkout@v4
- name: paths filter (kernel)
uses: dorny/paths-filter@v3
id: kern_filter
with:
base: ${{ github.ref_name }}
filters: |
amd64:
- 'sys/amd64/**'
i386:
- 'sys/i386/**'
aarch64:
- 'sys/arm64/**'
armv7:
- 'sys/arm/**'
powerpc: &ppc
- 'sys/powerpc/**'
powerpc64:
- *ppc
powerpc64le:
- *ppc
riscv64:
- 'sys/riscv/**'
all:
- '**/cross-bootstrap-tools.yml'
- name: paths filter (world)
uses: dorny/paths-filter@v3
id: world_filter
with:
base: ${{ github.ref_name }}
filters: |
amd64:
- 'sys/amd64/**.h'
i386:
- 'sys/i386/**.h'
aarch64:
- 'sys/arm64/**.h'
armv7:
- 'sys/arm/**.h'
powerpc: &ppc
- 'sys/powerpc/**.h'
powerpc64:
- *ppc
powerpc64le:
- *ppc
riscv64:
- 'sys/riscv/**.h'
all:
- '**/cross-bootstrap-tools.yml'
- name: match paths
shell: python
id: match
run: |
echo "files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.push.before }} ${{ github.sha }} | xargs)"
echo "files=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.push.before }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
import os
import json
all = ["amd64", "armv7", "aarch64", "i386", "powerpc", "powerpc64", "powerpc64le", "riscv64"]
out = open(os.environ['GITHUB_OUTPUT'], "a")
if ${{ steps.kern_filter.outputs.changes }} != []:
make_targets = ["buildkernel"]
if "${{ steps.kern_filter.outputs.all }}" == "true":
kern_archs = all
else:
kern_archs = json.loads(${{ steps.kern_filter.outputs.changes }})
kern_excl = list(set(all) ^ set(kern_archs))
if ${{ steps.world_filter.outputs.changes }} != []:
make_targets.append("buildworld")
if "${{ steps.world_filter.outputs.all }}" == "true":
world_archs = all
else:
world_archs = json.loads(${{ steps.world_filter.outputs.changes }})
world_excl = list(set(all) ^ set(world_archs))
print("kern_archs: ", kern_archs)
print("world_archs: ", world_archs)
exclude = '['
for a in kern_excl:
exclude += "{ make_target: buildkernel, target_arch: " + a + "},"
for a in world_excl:
exclude += "{ make_target: buildworld, target_arch: " + a + "},"
exclude = exclude[:-1] + ']'
if exclude == ']':
exclude = "[]"
print(exclude)
print("Writing exclude=" + exclude + '\n')
print("Writing make_targets=" + json.dumps(make_targets) + '\n')
print("Writing archs=" + json.dumps(list(set(world_archs + kern_archs))) + '\n')
out.write("exclude=" + exclude + '\n')
out.write("make_targets=" + json.dumps(make_targets) + '\n')
out.write("archs=" + json.dumps(list(set(world_archs + kern_archs))) + '\n')
out.close()
build:
name: ${{ matrix.target_arch }} buildkernel on ${{ matrix.os }} (${{ matrix.compiler }})
name: ${{ matrix.target_arch }} ${{ matrix.make_target }} on ${{ matrix.os }} (${{ matrix.compiler }})
runs-on: ${{ matrix.os }}
needs: modified_files
needs: setup
strategy:
fail-fast: false
matrix:
target_arch: [ amd64, aarch64, powerpc ]
target_arch: ${{ fromJSON(needs.setup.outputs.archs) }}
make_target: ${{ fromJSON(needs.setup.outputs.make_targets) }}

os: [ ubuntu-22.04, ubuntu-24.04, macos-latest ]
include:
# TODO: both Ubuntu and macOS have bmake packages, we should try them instead of bootstrapping our own copy.
Expand All @@ -79,17 +161,27 @@ jobs:
compiler: clang-18
cross-bindir: /opt/homebrew/opt/llvm@18/bin
pkgs: bmake libarchive llvm@18

# Correspoding TARGET for TARGET_ARCH
- target_arch: amd64
target: amd64
- target_arch: armv7
target: arm
- target_arch: aarch64
target: arm64
- target_arch: i386
target: i386
- target_arch: powerpc
target: powerpc
- target_arch: powerpc64
target: powerpc
- target_arch: powerpc64le
target: powerpc
- target_arch: riscv64
target: riscv
exclude: ${{ needs.setup.outputs.exclude }}
steps:
- uses: actions/checkout@v4
- name: check modified files
run: |
echo ${{ needs.modified_files.outputs.changes }} && exit 1
- name: install packages (Ubuntu)
if: runner.os == 'Linux'
run: |
Expand Down

0 comments on commit 06d9861

Please sign in to comment.