Skip to content

Commit

Permalink
GitHub workflows & setup: add support for dietpi:rpi_armv6_buster bas…
Browse files Browse the repository at this point in the history
…e image.
  • Loading branch information
f-laurens committed Jun 22, 2021
1 parent 4d34ebf commit e6b9b86
Show file tree
Hide file tree
Showing 8 changed files with 480 additions and 297 deletions.
File renamed without changes.
198 changes: 130 additions & 68 deletions .github/workflows/arm-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,85 +7,147 @@ on:
- 'fx[0-9]+.[0-9]+.[0-9]+*'
branches:
- 'releng'

jobs:
test:
test_suite:
name: Run test suite
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
base_image: ['raspios_lite:2021-05-07', 'dietpi:rpi_armv6_buster']

steps:
- uses: actions/checkout@v2
- name: Run tests in chroot environment
uses: pguyot/arm-runner-action@v1
id: arm_runner_tests
with:
image_additional_mb: 3584
base_image: 'raspios_lite:2021-05-07'
cpu: 'arm1176'
copy_repository_path: /home/pi/pynab
commands: |
sudo chown -R pi:pi /home/pi/pynab
- name: Checkout pynab
uses: actions/checkout@v2

- name: Run test suite in chroot environment
uses: pguyot/arm-runner-action@v1
id: arm_runner_tests
with:
image_additional_mb: 4096
base_image: ${{ matrix.base_image }}
cpu: 'arm1176'
copy_repository_path: /home/pi/pynab
commands: |
sudo useradd pi || true
sudo sh -c "[ ! -f /etc/sudoers.d/010_pi-nopasswd ] && usermod -aG sudo pi && echo 'pi ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/010_pi-nopasswd || true"
sudo chown -hR pi:pi /home/pi/pynab
sudo apt-get update -y
sudo apt-get install --no-install-recommends -y postgresql libpq-dev git python3 python3-venv python3-dev gettext nginx openssl libssl-dev libffi-dev libmpg123-dev libasound2-dev libatlas-base-dev libgfortran3 libopenblas-dev liblapack-dev zram-tools
sudo mkdir -p /run/systemd/timesync/ && sudo touch /run/systemd/timesync/synchronized
sudo apt-get install --no-install-recommends -y alsa-utils xz-utils avahi-daemon
sudo -u pi taskset -c 0 /bin/bash install.sh ci-chroot-test
- name: Upload image if tests failed
uses: actions/upload-artifact@v2
if: failure()
with:
name: Image of failed tests
path: ${{ steps.arm_runner_tests.outputs.image }}
create_image:
needs: test
name: Build image
runs-on: ubuntu-latest
needs: test_suite
strategy:
fail-fast: false
matrix:
base_image: ['raspios_lite:2021-05-07', 'dietpi:rpi_armv6_buster']
if: github.ref == 'refs/heads/releng' || startsWith(github.ref, 'refs/tags/')

steps:
- uses: actions/checkout@v2
- name: Define the image name
id: image_and_branch_name
run: |
if [ ${GITHUB_REF/refs\/tags\//} != ${GITHUB_REF} ]; then
echo ::set-output name=LOCAL_BRANCH::${GITHUB_REF/refs\/tags\//}
echo ::set-output name=IMAGE_NAME_SUFFIX::${GITHUB_REF/refs\/tags\//}
elif [ ${GITHUB_REF/refs\/heads\//} = "releng" ]; then
echo ::set-output name=LOCAL_BRANCH::releng
echo ::set-output name=IMAGE_NAME_SUFFIX::releng
else
echo ::set-output name=LOCAL_BRANCH::${GITHUB_REF/refs\/heads\//}
fi
- name: Create a release image in chroot environment
uses: pguyot/arm-runner-action@v1
id: arm_runner_install
with:
image_additional_mb: 3584
base_image: 'raspios_lite:2021-05-07'
cpu: 'arm1176'
commands: |
- name: Checkout pynab
uses: actions/checkout@v2

- name: Define the image name
id: image_and_branch_name
run: |
if [[ "${{ matrix.base_image }}" =~ "raspios" ]]; then
os_suffix="-raspios"
elif [[ "${{ matrix.base_image }}" =~ "dietpi" ]]; then
os_suffix="-dietpi"
else
os_suffix=""
fi
if [ ${GITHUB_REF/refs\/tags\//} != ${GITHUB_REF} ]; then
echo ::set-output name=LOCAL_BRANCH::${GITHUB_REF/refs\/tags\//}
echo ::set-output name=RELEASE_NAME::${GITHUB_REF/refs\/tags\//}
echo ::set-output name=IMAGE_NAME_SUFFIX::${GITHUB_REF/refs\/tags\//}${os_suffix}
elif [ ${GITHUB_REF/refs\/heads\//} = "releng" ]; then
echo ::set-output name=LOCAL_BRANCH::releng
echo ::set-output name=RELEASE_NAME::releng
echo ::set-output name=IMAGE_NAME_SUFFIX::releng${os_suffix}
else
echo ::set-output name=LOCAL_BRANCH::${GITHUB_REF/refs\/heads\//}
fi
- name: Create a release image in chroot environment
uses: pguyot/arm-runner-action@v1
id: arm_runner_install
with:
image_additional_mb: 4096
base_image: ${{ matrix.base_image }}
cpu: 'arm1176'
commands: |
echo GITHUB_BRANCH=${{ steps.image_and_branch_name.outputs.LOCAL_BRANCH }}
echo GITHUB_REPOSITORY=${{ github.repository }}
sudo GITHUB_BRANCH=${{ steps.image_and_branch_name.outputs.LOCAL_BRANCH }} GITHUB_REPOSITORY=${{ github.repository }} /bin/bash setup
sudo rm -rf /pynab
sudo apt-get autoremove -y
sudo GITHUB_BRANCH=${{ steps.image_and_branch_name.outputs.LOCAL_BRANCH }} GITHUB_REPOSITORY=${{ github.repository }} /bin/bash setup ci-chroot
cd / ; sudo rm -rf /pynab
sudo apt-get autoremove --purge -y
sudo apt-get clean
- name: Compress the release image with PiShrink
run: |
mv ${{ steps.arm_runner_install.outputs.image }} pynab-${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}.img
wget https://raw.githubusercontent.com/Drewsif/PiShrink/fa3c7a27406e7c0a1c7b8688e330f14a766be1ba/pishrink.sh
sudo bash pishrink.sh -Z -a pynab-${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}.img
- name: Create release with releng image
if: github.ref == 'refs/heads/releng'
uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
draft: true
title: "Prerelease image"
files: pynab-${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}.img.xz
- name: Create release with release image
if: startsWith(github.ref, 'refs/tags/')
uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}
prerelease: false
draft: true
title: ${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}
files: pynab-${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}.img.xz
sudo sh -c 'cat /dev/zero >/boot/zero.fill 2>/dev/null; sync; rm -f /boot/zero.fill'
sudo sh -c 'cat /dev/zero >/zero.fill 2>/dev/null; sync; rm -f /zero.fill'
- name: Compress the release image with PiShrink
run: |
mv ${{ steps.arm_runner_install.outputs.image }} pynab-${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}.img
wget https://raw.githubusercontent.com/Drewsif/PiShrink/fa3c7a27406e7c0a1c7b8688e330f14a766be1ba/pishrink.sh
sudo bash pishrink.sh -s -Z -a -p pynab-${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}.img
- name: Upload the image artifact
uses: actions/upload-artifact@v2
with:
name: release_images
path: pynab-${{ steps.image_and_branch_name.outputs.IMAGE_NAME_SUFFIX }}.img.xz
if-no-files-found: error
retention-days: 1

create_release:
name: Release
runs-on: ubuntu-latest
needs: create_image
if: github.ref == 'refs/heads/releng' || startsWith(github.ref, 'refs/tags/')

steps:
- name: Define the release name
id: release_name
run: |
if [ ${GITHUB_REF/refs\/tags\//} != ${GITHUB_REF} ]; then
echo ::set-output name=RELEASE_NAME::${GITHUB_REF/refs\/tags\//}
elif [ ${GITHUB_REF/refs\/heads\//} = "releng" ]; then
echo ::set-output name=RELEASE_NAME::releng
else
echo ::set-output name=RELEASE_NAME::${GITHUB_REF/refs\/heads\//}
fi
- name: Download the image artifact(s)
uses: actions/download-artifact@v2
with:
name: release_images

- name: Create release with releng image
if: github.ref == 'refs/heads/releng'
uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
draft: true
title: "Prerelease"
files: pynab-${{ steps.release_name.outputs.RELEASE_NAME }}*.img.xz

- name: Create release with release image
if: startsWith(github.ref, 'refs/tags/')
uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ steps.release_name.outputs.RELEASE_NAME }}
prerelease: false
draft: true
title: ${{ steps.release_name.outputs.RELEASE_NAME }}
files: pynab-${{ steps.release_name.outputs.RELEASE_NAME }}*.img.xz
15 changes: 6 additions & 9 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
# This workflow will apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/labels.yml
# file with configuration. For more information, see:
# https://github.com/marketplace/actions/prow-github-actions

name: 🏷️ Pull Request Labeler
on:
- pull_request_target

jobs:
triage:
pr_triage:
runs-on: ubuntu-latest

steps:
- uses: actions/labeler@main
- name: Apply labels
uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labels.yml
sync-labels: true
Loading

0 comments on commit e6b9b86

Please sign in to comment.