Skip to content

Commit

Permalink
Abstract out shared workflow logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Nycto committed Mar 17, 2024
1 parent e3c6cc7 commit d21b779
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 72 deletions.
34 changes: 34 additions & 0 deletions .github/actions/build-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Common build setup
runs:
using: "composite"
steps:

- name: Git safe directory
shell: bash
run: git config --global --add safe.directory "$(pwd)"

# Some of the apt dependencies require input from the installer. This disables those
# prompts so we can do a headless install
- name: Force non-interactive apt installations
shell: bash
run: echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

- name: Update Apt dependencies
shell: bash
run: apt-get update

- name: Install apt dependencies
shell: bash
run: apt-get install -y libpng16-16 gcc-arm-none-eabi wget

- name: Download playdate SDK
shell: bash
run: wget -qO- https://download.panic.com/playdate_sdk/linux/playdatesdk-latest.tar.gz | tar xvz

- name: Set PLAYDATE_SDK_PATH
shell: bash
run: echo "PLAYDATE_SDK_PATH=$(readlink -f $(find PlaydateSDK-* -maxdepth 0 -type d))" >> "$GITHUB_ENV"

- name: Locally publish playdate nimble package
shell: bash
run: nimble develop
102 changes: 30 additions & 72 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,46 @@
name: Build
on: [push, pull_request]
jobs:
build:

example-project:
runs-on: ubuntu-latest
container: nimlang/nim
strategy:
matrix:
target: [ device, simulator ]
steps:

# Some of the apt dependencies require input from the installer. This disables those
# prompts so we can do a headless install
- name: Force non-interactive apt installations
run: echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

- name: Update dependencies
run: apt-get update
- name: Install dependencies
run: apt-get install -y libpng16-16 gcc-arm-none-eabi
- uses: actions/checkout@v1
- name: Download playdate SDK
run: wget https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-latest.tar.gz
- name: Extract playdate SDK
run: tar -xvzf PlaydateSDK-latest.tar.gz
- name: Local publish playdate
run: nimble develop
- name: Tests
run: |
export PLAYDATE_SDK_PATH=$(readlink -f $(find PlaydateSDK-* -maxdepth 0 -type d));
nimble test;
- name: Setup
run: |
export PLAYDATE_SDK_PATH=$(readlink -f $(find PlaydateSDK-* -maxdepth 0 -type d));
cd playdate_example;
nimble playdateSetup;
- name: Install dependencies
working-directory: ./playdate_example
run: nimble install --depsOnly --accept
- name: Simulator
working-directory: ./playdate_example
run: nimble simulator
- name: Device
- uses: actions/checkout@v3
- uses: ./.github/actions/build-setup
- uses: ./.github/actions/project-setup
with:
working-directory: ./playdate_example
- run: nimble ${{ matrix.target }}
working-directory: ./playdate_example
run: nimble device

simulate:
tests:
runs-on: ubuntu-latest
container: nimlang/nim
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build-setup
- run: nimble test

headless-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
container: nimlang/nim
env:
HOME: /config
steps:

# Some of the apt dependencies require input from the installer. This disables those
# prompts so we can do a headless install
- name: Force non-interactive apt installations
run: echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
- uses: actions/checkout@v3

- uses: ./.github/actions/build-setup

- uses: ./.github/actions/project-setup
with:
working-directory: ./tests

- name: Update dependencies
run: apt-get update
- name: Install dependencies
run: apt-get install -y libpng16-16 gcc-arm-none-eabi xvfb libgtk-3-0 sudo libwebkit2gtk-4.0 libwebkit2gtk-4.0-dev libsdl2-dev pulseaudio
run: apt-get install -y xvfb libgtk-3-0 sudo libwebkit2gtk-4.0 libwebkit2gtk-4.0-dev libsdl2-dev pulseaudio

# Because we are headless there is no audio driver to interact with by default, which causes a set
# of warnings to be emitted. This set of commands sets up a dummy audio sink that silences those warnings.
Expand All @@ -66,32 +49,8 @@ jobs:
pulseaudio -D --exit-idle-time=-1
pactl load-module module-null-sink sink_name=SpeakerOutput sink_properties=device.description="Dummy_Output"
- name: Checkout commit
uses: actions/checkout@v1

- name: Download playdate SDK
run: wget https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-latest.tar.gz
- name: Extract playdate SDK
run: tar -xvzf PlaydateSDK-latest.tar.gz

- name: Local publish playdate
run: nimble develop

- name: Install dependencies
working-directory: ./tests
run: nimble install --depsOnly --accept

# The tests need to be told where the SDK is. Running `setup` with the SDK path configured
# will fill that in
- name: Setup tests
run: |
export PLAYDATE_SDK_PATH=$(readlink -f $(find PlaydateSDK-* -maxdepth 0 -type d));
cd tests;
nimble playdateSetup;
- name: Compile for simulator
- run: nimble simulator
working-directory: ./tests
run: nimble simulator

# The first time the simulator runs, it prompts the user with an alert. Obviously, we're running headless,
# so this prevents the tests from running without closing that alert. Creating this ini file will stop that
Expand All @@ -105,6 +64,5 @@ jobs:
echo "ShowElist=0" >> $PD_INI_FILE
echo "LastRelease=$(cat PlaydateSDK-*/VERSION.txt)" >> $PD_INI_FILE
- name: Run headless test
- run: xvfb-run ../PlaydateSDK-*/bin/PlaydateSimulator tests.pdx
working-directory: ./tests
run: xvfb-run ../PlaydateSDK-*/bin/PlaydateSimulator tests.pdx

0 comments on commit d21b779

Please sign in to comment.