Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
jcapona committed Jul 30, 2024
1 parent 8175c78 commit ac71cdb
Showing 1 changed file with 100 additions and 94 deletions.
194 changes: 100 additions & 94 deletions .github/workflows/pt-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,101 +39,107 @@ jobs:
with:
fetch-depth: 0

- uses: aarcangeli/load-dotenv@v1.0.0

- name: Get build type and RPi OS image name
run: |
build_type="${{ matrix.architecture }}${{ matrix.build_type_suffix }}"
echo "BUILD_TYPE=${build_type}" >> $GITHUB_ENV
echo "IMAGE_NAME=${{ env.RASPIOS_BUILD_DATE }}-raspios-${{ inputs.distro_name }}-${build_type}" >> $GITHUB_ENV
- name: Install ansible and playbook dependencies
# Install 'qemu-user-static' >v5 to allow 'arm64' chroot
# 'ubuntu-20.04' (currently latest) does not have an up-to-date version, so we install from `ubuntu-security` repo
run: |
wget http://old-releases.ubuntu.com/ubuntu/pool/universe/q/qemu/qemu-user-static_5.2+dfsg-9ubuntu3.1_amd64.deb
sudo apt-get update && sudo apt-get install -y \
ansible \
unzip \
zerofree \
./qemu-user-static_5.2+dfsg-9ubuntu3.1_amd64.deb
- name: Build
# - uses: aarcangeli/load-dotenv@v1.0.0

# - name: Get build type and RPi OS image name
# run: |
# build_type="${{ matrix.architecture }}${{ matrix.build_type_suffix }}"
# echo "BUILD_TYPE=${build_type}" >> $GITHUB_ENV
# echo "IMAGE_NAME=${{ env.RASPIOS_BUILD_DATE }}-raspios-${{ inputs.distro_name }}-${build_type}" >> $GITHUB_ENV

# - name: Install ansible and playbook dependencies
# # Install 'qemu-user-static' >v5 to allow 'arm64' chroot
# # 'ubuntu-20.04' (currently latest) does not have an up-to-date version, so we install from `ubuntu-security` repo
# run: |
# wget http://old-releases.ubuntu.com/ubuntu/pool/universe/q/qemu/qemu-user-static_5.2+dfsg-9ubuntu3.1_amd64.deb

# sudo apt-get update && sudo apt-get install -y \
# ansible \
# unzip \
# zerofree \
# ./qemu-user-static_5.2+dfsg-9ubuntu3.1_amd64.deb

# - name: Build
# run: |
# export ANSIBLE_FORCE_COLOR=true
# export TERM=xterm-color
# # chroot connection requires running as root
# # 'ansible-playbook' is not in root user's PATH
# ANSIBLE="sudo $(which ansible-playbook) -i inventory -vv"

# build_type_dir="raspios_$(echo ${{ env.BUILD_TYPE }} | python3 -c "import sys; print('_'.join(reversed(sys.stdin.read().strip().split('-'))))")"
# url="https://downloads.raspberrypi.org/${build_type_dir}/images/${build_type_dir}-${{ env.RASPIOS_RELEASE_DATE }}/${{ env.IMAGE_NAME }}.img.xz"

# echo "==> Running get_raspios playbook..."
# ${ANSIBLE} --extra-vars "raspi_os_url=${url}" \
# --extra-vars "image_name=${{ env.IMAGE_NAME }}" \
# playbooks/get_raspios.yml

# echo "==> Running mount_raspios playbook..."
# ${ANSIBLE} --extra-vars "image_name=${{ env.IMAGE_NAME }}" \
# playbooks/mount_raspios.yml

# echo "==> Running create_pi_top_os_image playbook..."
# ${ANSIBLE} playbooks/create_pi_top_os_image.yml

# echo "==> Running mount_pi_top_os playbook..."
# ${ANSIBLE} playbooks/mount_pi_top_os.yml

# echo "==> Running install_pi_top_os playbook..."
# ${ANSIBLE} --extra-vars "repo_name=${{ inputs.repo_name }}" \
# --extra-vars "distro_name=${{ inputs.distro_name }}" \
# --extra-vars "top_level_pkg=pt-os${{ matrix.build_type_suffix }}" \
# --extra-vars "{'full_install': ${{ matrix.build_type_suffix == '' }}}" \
# playbooks/install_pi_top_os.yml

# echo "==> Running configure_pi_top_os playbook..."
# ${ANSIBLE} --extra-vars "distro_name=${{ inputs.distro_name }}" \
# --extra-vars "build_number=${{ github.run_number || github.run_id }}" \
# --extra-vars "build_repo_commit=$(git rev-parse HEAD)" \
# --extra-vars "build_repo_commit_short=$(git rev-parse --short HEAD)" \
# --extra-vars "build_action_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
# --extra-vars "build_repo_name=${{ inputs.repo_name }}" \
# --extra-vars "build_type=${{ env.BUILD_TYPE }}" \
# playbooks/configure_pi_top_os.yml

# echo "==> Running finalise_pi_top_image playbook..."
# ${ANSIBLE} --extra-vars "distro_name=${{ inputs.distro_name }}" \
# --extra-vars "build_number=${{ github.run_number || github.run_id }}" \
# --extra-vars "build_repo_name=${{ inputs.repo_name }}" \
# --extra-vars "build_type=${{ env.BUILD_TYPE }}" \
# playbooks/finalise_pi_top_image.yml

# echo "==> Running analyse_build playbook..."
# ${ANSIBLE} --extra-vars "build_number=${{ github.run_number || github.run_id }}" \
# playbooks/analyse_build.yml

# - name: Cleanup (to avoid CI space issues)
# run: |
# ls -l playbooks/artifacts
# sudo rm -f playbooks/artifacts/*.img
# ls -l playbooks/artifacts

# - name: Get current date
# id: date
# run: echo "DATE_STAMP=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

# - name: Upload OS zip contents
# uses: actions/upload-artifact@v3
# with:
# name: pi-topOS_${{ inputs.distro_name }}_${{ inputs.repo_name }}_${{ env.BUILD_TYPE }}_${{ env.DATE_STAMP }}_B${{ github.run_number || github.run_id }}
# if-no-files-found: error
# path: |
# playbooks/artifacts/*

# - name: Print metadata
# run: cat playbooks/artifacts/metadata.txt

- name: Test
run: |
export ANSIBLE_FORCE_COLOR=true
export TERM=xterm-color
# chroot connection requires running as root
# 'ansible-playbook' is not in root user's PATH
ANSIBLE="sudo $(which ansible-playbook) -i inventory -vv"
build_type_dir="raspios_$(echo ${{ env.BUILD_TYPE }} | python3 -c "import sys; print('_'.join(reversed(sys.stdin.read().strip().split('-'))))")"
url="https://downloads.raspberrypi.org/${build_type_dir}/images/${build_type_dir}-${{ env.RASPIOS_RELEASE_DATE }}/${{ env.IMAGE_NAME }}.img.xz"
echo "==> Running get_raspios playbook..."
${ANSIBLE} --extra-vars "raspi_os_url=${url}" \
--extra-vars "image_name=${{ env.IMAGE_NAME }}" \
playbooks/get_raspios.yml
echo "==> Running mount_raspios playbook..."
${ANSIBLE} --extra-vars "image_name=${{ env.IMAGE_NAME }}" \
playbooks/mount_raspios.yml
echo "==> Running create_pi_top_os_image playbook..."
${ANSIBLE} playbooks/create_pi_top_os_image.yml
echo "==> Running mount_pi_top_os playbook..."
${ANSIBLE} playbooks/mount_pi_top_os.yml
echo "==> Running install_pi_top_os playbook..."
${ANSIBLE} --extra-vars "repo_name=${{ inputs.repo_name }}" \
--extra-vars "distro_name=${{ inputs.distro_name }}" \
--extra-vars "top_level_pkg=pt-os${{ matrix.build_type_suffix }}" \
--extra-vars "{'full_install': ${{ matrix.build_type_suffix == '' }}}" \
playbooks/install_pi_top_os.yml
echo "==> Running configure_pi_top_os playbook..."
${ANSIBLE} --extra-vars "distro_name=${{ inputs.distro_name }}" \
--extra-vars "build_number=${{ github.run_number || github.run_id }}" \
--extra-vars "build_repo_commit=$(git rev-parse HEAD)" \
--extra-vars "build_repo_commit_short=$(git rev-parse --short HEAD)" \
--extra-vars "build_action_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
--extra-vars "build_repo_name=${{ inputs.repo_name }}" \
--extra-vars "build_type=${{ env.BUILD_TYPE }}" \
playbooks/configure_pi_top_os.yml
echo "==> Running finalise_pi_top_image playbook..."
${ANSIBLE} --extra-vars "distro_name=${{ inputs.distro_name }}" \
--extra-vars "build_number=${{ github.run_number || github.run_id }}" \
--extra-vars "build_repo_name=${{ inputs.repo_name }}" \
--extra-vars "build_type=${{ env.BUILD_TYPE }}" \
playbooks/finalise_pi_top_image.yml
echo "==> Running analyse_build playbook..."
${ANSIBLE} --extra-vars "build_number=${{ github.run_number || github.run_id }}" \
playbooks/analyse_build.yml
- name: Cleanup (to avoid CI space issues)
run: |
ls -l playbooks/artifacts
sudo rm -f playbooks/artifacts/*.img
ls -l playbooks/artifacts
- name: Get current date
id: date
run: echo "DATE_STAMP=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

- name: Upload OS zip contents
uses: actions/upload-artifact@v3
with:
name: pi-topOS_${{ inputs.distro_name }}_${{ inputs.repo_name }}_${{ env.BUILD_TYPE }}_${{ env.DATE_STAMP }}_B${{ github.run_number || github.run_id }}
if-no-files-found: error
path: |
playbooks/artifacts/*
- name: Print metadata
run: cat playbooks/artifacts/metadata.txt

mkdir -p playbooks/artifacts
touch playbooks/artifacts/test.zip
ls -l playbooks/artifacts/*.zip
- name: Upload OS zip to GCS
uses: google-github-actions/upload-cloud-storage@v0.4.0
with:
Expand Down

0 comments on commit ac71cdb

Please sign in to comment.