Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
trombik committed Oct 16, 2024
1 parent b38e407 commit f9cd01a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
PORTS_TO_BUILD_JSON: ${{ steps.list-ports-to-build.outputs.PORTS_TO_BUILD_JSON }}
BUILD_ALL_PORTS_JSON: ${{ steps.build-all-ports.outputs.BUILD_ALL_PORTS_JSON }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -25,18 +26,33 @@ jobs:
- name: Build all ports in the repository
if: steps.filter.outputs.ci == 'true'
id: build-all-ports
run: |
echo "steps.filter.outputs.ci_files: '${{ steps.filter.outputs.ci_files }}'"
echo "::notice ::Building all the ports in the repository"
# find ports in the repository and make it a list of one line
# separated by a space.
PORTS_TO_BUILD=`find * -type d -maxdepth 1 -mindepth 1 | tr '\n' ' ' | sed -e 's/ $//'`
# create a JSON from the list
PORTS_TO_BUILD_JSON=`jq -n -c -M --arg V "${PORTS_TO_BUILD}" '{ PORT: ($V | split(" ")) }'`
# pass the JSON to other jobs
echo "BUILD_ALL_PORTS_JSON=${PORTS_TO_BUILD_JSON}" >> "${GITHUB_OUTPUT}"
- name: List ports-to-build
if: steps.filter.outputs.ports-to-build == 'true' && steps.filter.outputs.ci != 'true'
id: list-ports-to-build
run: |
echo "steps.filter.outputs.ports-to-build_files: 'steps.filter.outputs.ports-to-build_files }}'"
# find ports in the repository and make it a list of one line
# separated by a space.
PORTS_TO_BUILD=`find * -type d -maxdepth 1 -mindepth 1 | tr '\n' ' ' | sed -e 's/ $//'`
echo "steps.filter.outputs.ports-to-build_files: '${{ steps.filter.outputs.ports-to-build_files }}'"
# find changed ports in the repository and make it a list of one
# line separated by a space.
for F in ${{ steps.filter.outputs.ports-to-build_files }}; do
PORTS_TO_BUILD="${PORTS_TO_BUILD} `echo ${F} | cut -f 1,2 -d '/' | sort -u | grep '/'`
done
PORTS_TO_BUILD=`echo ${PORTS_TO_BUILD} | tr '\n' ' ' | sed -e 's/ $//'`
echo "::notice ::Building ${PORTS_TO_BUILD}"
# create a JSON from the list
Expand All @@ -51,5 +67,12 @@ jobs:
needs: list-ports
steps:
- name: Build ports
shell: sh
run: |
echo "${{ needs.list-ports.outputs.PORTS_TO_BUILD_JSON }}"
if [ ! -z needs.list-ports.outputs.BUILD_ALL_PORTS_JSON ]; then
echo "Building ${{ needs.list-ports.outputs.BUILD_ALL_PORTS_JSON }}"
elif [ -z ${{ needs.list-ports.outputs.PORTS_TO_BUILD_JSON }}; then
echo "Building ${{ needs.list-ports.outputs.PORTS_TO_BUILD_JSON }}"
else
echo "Building none"
fi
25 changes: 3 additions & 22 deletions .github/workflows/poudriere.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Build all ports in the repository
name: Build ports in the repository

# this workflow works when:
#
Expand All @@ -18,33 +18,14 @@ on:
workflow_call:
inputs:
ports-to-build:
description: A space separated string of ports, in the format of category/name
description: A JSON with '{ "PORT": [ "category/name", "category/another" ] }'
required: false
type: string

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
list-ports:
runs-on: ubuntu-latest
outputs:
PORTS_TO_BUILD_JSON: ${{ steps.list_ports_to_build.outputs.PORTS_TO_BUILD_JSON }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Create a list of ports to build
id: list_ports_to_build
shell: sh
run: |
# create a JSON from the list
PORTS_TO_BUILD_JSON=`jq -n -c -M --arg V "${{ inputs.ports-to-build }}" '{ PORT: ($V | split(" ")) }'`
# pass the JSON to other jobs
echo "PORTS_TO_BUILD_JSON=${PORTS_TO_BUILD_JSON}" >> "${GITHUB_OUTPUT}"
cat "${GITHUB_OUTPUT}"
build:
runs-on: ubuntu-latest
needs:
Expand All @@ -56,7 +37,7 @@ jobs:
# https://docs.github.com/en/actions/administering-github-actions/usage-limits-billing-and-administration
#
# each job builds one port in the repository
matrix: ${{ fromJSON(needs.list-ports.outputs.PORTS_TO_BUILD_JSON) }}
matrix: ${{ fromJSON(inputs.ports-to-build) }}

# do not cancel other jobs in the matrix when a job fails.
fail-fast: false
Expand Down

0 comments on commit f9cd01a

Please sign in to comment.