Skip to content

Commit

Permalink
Test new workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiaswal committed Jan 29, 2025
1 parent 94865a7 commit 58e49ce
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 39 deletions.
194 changes: 168 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
name: Bob the Builder

on:
#pull_request:
#push:
# branches:
# - main
pull_request:
types: [opened, synchronize, reopened, labeled]
push:
branches:
- main
workflow_dispatch:
inputs:
minimal:
description: 'Build minimal defconfigs'
required: false
default: true
type: boolean

jobs:
build:
if: ${{github.ref_name == 'main' && github.event_name == 'push'}} || github.event_name == 'workflow_dispatch'
name: Vendor example build [${{ matrix.platform }}]
runs-on: [self-hosted, latest]
name: Build Vendor example Infix ${{ matrix.target }}
runs-on: [ self-hosted, latest ]
strategy:
matrix:
platform: [aarch64, x86_64]
target: [aarch64, x86_64]
fail-fast: false
outputs:
build_id: ${{ steps.vars.outputs.INFIX_BUILD_ID }}
steps:
- name: Cleanup Build Folder
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- uses: actions/checkout@v4
with:
clean: true
Expand All @@ -25,58 +40,184 @@ jobs:
- name: Set Build Variables
id: vars
run: |
target=${{ matrix.platform }}
if [ -n "${{ github.event.pull_request.head.sha }}" ]; then
# Since PRs are built from an internally generated merge
# commit, reverse lookups of PRs and/or commits from
# image version information are cumbersome. Therefore:
# explicitly set a build id that references both the PR
# and the commit.
printf "INFIX_BUILD_ID=pr%d.%.7s\n" \
"${{ github.event.number }}" "${{ github.event.pull_request.head.sha }}" \
| tee -a $GITHUB_OUTPUT $GITHUB_ENV
fi
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ "${{ github.event.inputs.minimal }}" == "true" ]; then
flavor="_minimal"
fi
else
# Ensure 'release' job get the proper image when building main
if [ "$GITHUB_REF_NAME" != "main" ]; then
flavor="_minimal"
else
flavor=""
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'ci:main') }}; then
flavor=""
fi
fi
target=${{ matrix.target }}
echo "dir=vendor-example-$target" >> $GITHUB_OUTPUT
echo "tgz=vendor-example-$target.tar.gz" >> $GITHUB_OUTPUT
echo "flv=$flavor" >> $GITHUB_OUTPUT
echo "Building target ${target}${flavor}_defconfig"
- name: Restore Cache of dl/
uses: actions/cache@v4
with:
path: dl/
key: dl-${{ matrix.platform }}-${{ hashFiles('.git/modules/infix/refs/heads/main', 'configs/*') }}
key: dl-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }}
restore-keys: |
dl-${{ matrix.platform }}-
dl-
- name: Restore Cache of .ccache/
uses: actions/cache@v4
with:
path: .ccache/
key: ccache-${{ matrix.platform }}-${{ hashFiles('.git/modules/infix/refs/heads/main', 'configs/*') }}
key: ccache-${{ matrix.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
restore-keys: |
ccache-${{ matrix.platform }}-
ccache-${{ matrix.target }}-
ccache-
- name: Configure & Build
- name: Configure ${{ matrix.target }}${{ steps.vars.outputs.flv }}
run: |
make ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig
- name: Unit Test ${{ matrix.target }}
run: |
make test-unit
- name: Build ${{ matrix.target }}${{ steps.vars.outputs.flv }}
run: |
target=${{ matrix.platform }}_vendor_example_defconfig
echo "Buildring $target ..."
make $target
echo "Building ${{ matrix.target }}${{ steps.vars.outputs.flv }}_defconfig ..."
make
- name: Prepare Artifact
- name: Check SBOM from Build
run: |
make legal-info
- name: Build test specification
run: |
make test-spec
- name: Resulting size of build
run: |
printf "Size of complete tree : "
du -sh .
printf "Size of output/ : "
du -sh output
printf "Size of dl/ : "
du -sh dl
printf "Size of output/images/: "
ls -l output/images/
- name: Prepare ${{ matrix.target }} Artifact
run: |
cd output
cd output/
mv images ${{ steps.vars.outputs.dir }}
ln -s ${{ steps.vars.outputs.dir }} images
tar chfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}
- uses: actions/upload-artifact@v4
with:
path: output/${{ steps.vars.outputs.tgz }}
name: artifact-${{ matrix.platform }}
name: artifact-${{ matrix.target }}

test:
name: Regression Test of Vendor example Infix x86_64
needs: build
runs-on: [ self-hosted, regression ]
steps:
- uses: actions/checkout@v4
with:
clean: true
submodules: recursive

- name: Set Build Variables
id: vars
run: |
if [ -n "${{ needs.build.outputs.build_id }}" ]; then
echo "INFIX_BUILD_ID=${{ needs.build.outputs.build_id }}" \
>>$GITHUB_ENV
fi
if [ "$GITHUB_REF_NAME" != "main" ]; then
flavor="_minimal"
else
flavor=""
fi
echo "flv=$flavor" >> $GITHUB_OUTPUT
- name: Configure x86_64${{ steps.vars.outputs.flv }}
run: |
make x86_64${{ steps.vars.outputs.flv }}_defconfig
- uses: actions/download-artifact@v4
with:
pattern: "artifact-*"
merge-multiple: true

- name: Restore x86-64${{ steps.vars.outputs.flv }} output/
run: |
ls -l
mkdir -p output
mv vendor-example-x86_64.tar.gz output/
cd output/
tar xf vendor-example-x86_64.tar.gz
ln -s vendor-example-x86_64 images
- name: Regression Test x86_64${{ steps.vars.outputs.flv }}
run: |
make test
- name: Publish Test Result for x86_64${{ steps.vars.outputs.flv }}
# Ensure this runs even if Regression Test fails
if: always()
run: cat infix/test/.log/last/result-gh.md >> $GITHUB_STEP_SUMMARY

- name: Generate Test Report for x86_64${{ steps.vars.outputs.flv }}
# Ensure this runs even if Regression Test fails
if: always()
run: |
asciidoctor-pdf \
--theme infix/test/9pm/report/theme.yml \
-a pdf-fontsdir=infix/test/9pm/report/fonts \
infix/test/.log/last/report.adoc \
-o infix/test/.log/last/report.pdf
- name: Upload Test Report as Artifact
uses: actions/upload-artifact@v4
with:
name: test-report
path: infix/test/.log/last/report.pdf

release:
if: github.repository == 'kernelkit/vendor-example' && github.ref == 'refs/heads/main'
permissions: write-all
if: ${{github.repository_owner == 'kernelkit' && github.ref_name == 'main'}}
name: Upload Latest Build
needs: build
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: "artifact-*"
merge-multiple: true

- name: Create checksums ...
run: |
for file in *.tar.gz; do
sha256sum $file > $file.sha256
done
- uses: ncipollo/release-action@v1
with:
allowUpdates: true
Expand All @@ -86,12 +227,13 @@ jobs:
prerelease: true
tag: "latest"
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "*.tar.gz"
artifacts: "*.tar.gz*"

- name: Summary
run: |
cat <<EOF >> $GITHUB_STEP_SUMMARY
# Latest Build Complete! :rocket:
For the public download links of these build artifacts, please see:
<https://github.com/kernelkit/vendor-example/releases/tag/latest>
EOF
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
echo "pre=false" >> $GITHUB_OUTPUT
fi
target=${{ matrix.target }}-${ver}
echo "dir=dcp-sc-28p-$target" >> $GITHUB_OUTPUT
echo "tgz=dcp-sc-28p-$target.tar.gz" >> $GITHUB_OUTPUT
echo "dir=vendor-example-$target" >> $GITHUB_OUTPUT
echo "tgz=vendor-example-$target.tar.gz" >> $GITHUB_OUTPUT
- name: Restore Cache of dl/
uses: actions/cache@v4
Expand Down
57 changes: 47 additions & 10 deletions .github/workflows/sync-infix.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
name: Automatically sync Infix

on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
permissions:
contents: write

jobs:
commit:
check_changes:
runs-on: [ self-hosted, latest ]
if: ${{ env.SYNC_INFIX }}
if: ${{ vars.SYNC_INFIX }}
outputs:
has_changes: ${{ steps.check_changes.outputs.has_changes }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.COMMIT_TOKEN }}
fetch-depth: 0
submodules: true

- name: Check for updates on infix and commit them
- name: Check for updates and commit if needed
id: check_changes
run: |
git config --global user.name 'Wires bot'
git config --global user.email 'noreply@wires.se'
CHANGES=0
if git ls-remote --heads origin latest | grep -q latest; then
echo "Latest exists, checking out"
git checkout latest
if [[ -n "$(git diff --exit-code origin/main)" ]]; then
echo "New commits exist on main"
git merge origin/main
CHANGES=1
fi
git submodule update --init --recursive
else
echo "Latest does not exist, create it"
git checkout -b latest
fi
cd infix
git clean -ffdx
git checkout main
git pull origin main
cd ..
Expand All @@ -52,6 +57,38 @@ jobs:
CHANGES=1
fi
if [ $CHANGES -eq 1 ]; then
git push origin latest
fi
echo "has_changes=$CHANGES" >> $GITHUB_OUTPUT
- name: Cache repository state
if: steps.check_changes.outputs.has_changes == '1'
run: |
# Save the current directory state
tar -czf /tmp/repo-state.tar.gz .
- uses: actions/cache/save@v3
if: steps.check_changes.outputs.has_changes == '1'
with:
path: /tmp/repo-state.tar.gz
key: repo-state-${{ github.run_id }}

push_changes:
needs: check_changes
if: needs.check_changes.outputs.has_changes == '1'
runs-on: [ self-hosted, latest ]
steps:
- uses: actions/cache/restore@v3
with:
path: /tmp/repo-state.tar.gz
key: repo-state-${{ github.run_id }}
fail-on-cache-miss: true

- name: Restore repository state and push
run: |
# Restore the repository state
rm -rf *
tar -xzf /tmp/repo-state.tar.gz
# Configure git and push
git config --global user.name 'Wires bot'
git config --global user.email 'noreply@wires.se'
git push origin latest
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Vendor example for infix

This repo is an example of how to extend standard Infix
This repo is an example of how to extend standard Infix.

0 comments on commit 58e49ce

Please sign in to comment.