Skip to content

Commit

Permalink
Merge branch 'main' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
samdze authored Feb 18, 2025
2 parents 9bde8eb + d95cd14 commit cdfc645
Show file tree
Hide file tree
Showing 56 changed files with 4,839 additions and 527 deletions.
54 changes: 54 additions & 0 deletions .github/actions/build-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Common build setup
inputs:
nim-version:
required: true
runs:
using: "composite"
steps:

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

- name: Install Nim
shell: bash
run: choosenim -y update ${{ inputs.nim-version }}

- run: nimble --accept refresh
shell: bash

- run: nimble install --verbose
shell: bash

- run: echo "/github/home/.nimble/bin" >> $GITHUB_PATH
shell: bash

- run: which pdn
shell: bash

- name: Locally publish playdate nimble package
shell: bash
if: ${{ startsWith(inputs.nim-version, '1.') }}
run: nimble develop

# 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"
39 changes: 39 additions & 0 deletions .github/actions/macos-build-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: macos build setup
inputs:
nim-version:
required: true
runs:
using: "composite"
steps:

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

- uses: iffy/install-nim@v5
with:
version: ${{ inputs.nim-version }}
- run: nimble --accept refresh
shell: bash

- run: nimble install
shell: bash

- name: Locally publish playdate nimble package
shell: bash
if: ${{ startsWith(inputs.nim-version, '1.') }}
run: nimble develop

- name: Install Playdate SDK
id: playdate
uses: pd-rs/[email protected]
with:
version: latest # possible values: version `x.x.x` or `latest` by default

- name: print playdate sdk info
shell: bash
run: |
echo "SDK path env: $PLAYDATE_SDK_PATH"
echo "SDK root out: ${{ steps.playdate.outputs.root }}"
echo "SDK version: ${{ steps.playdate.outputs.version }}"
pdc --version # because SDK/bin already in PATH
12 changes: 12 additions & 0 deletions .github/actions/project-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Common setup steps for a playdate nimble project
inputs:
working-directory:
required: true
runs:
using: "composite"
steps:

- name: Install dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: nimble install --depsOnly --accept
137 changes: 63 additions & 74 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,104 +1,91 @@
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
container: nimlang/nim
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 setup;
- name: Install dependencies
working-directory: ./playdate_example
run: nimble install --depsOnly --accept
- name: Simulator
compile-example-project-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/macos-build-setup
with:
nim-version: 2.0.8
- uses: ./.github/actions/project-setup
with:
working-directory: ./playdate_example
- run: pdn simulator
working-directory: ./playdate_example
run: nimble simulator
- name: Device

example-project:
strategy:
matrix:
target: [ device, simulator ]
nim-version: [ 2.0.8 ]
runs-on: ubuntu-latest
container: nimlang/choosenim
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build-setup
with:
nim-version: ${{ matrix.nim-version }}
- uses: ./.github/actions/project-setup
with:
working-directory: ./playdate_example
- run: pdn ${{ matrix.target }}
working-directory: ./playdate_example
run: nimble device

simulate:
tests:
runs-on: ubuntu-latest
container: nimlang/choosenim
strategy:
matrix:
nim-version: [ 2.0.8 ]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build-setup
with:
nim-version: ${{ matrix.nim-version }}
- run: nimble test

headless-tests:
runs-on: ubuntu-latest
timeout-minutes: 5
container: nimlang/nim
env:
HOME: /config
container: nimlang/choosenim
strategy:
matrix:
nim-version: [ 2.0.8 ]
build-flags: [ noflag, memProfiler, memtrace, memrecord ]
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
with:
nim-version: ${{ matrix.nim-version }}

- 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.
- name: Setup audio sink
run: |
export HOME="/config"
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 setup;
- name: Compile for simulator
- run: pdn simulator -d:${{ matrix.build-flags }}
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
# alert from showing in the first place
- name: Create simulator ini
run: |
export PD_INI_DIR="$HOME/.Playdate Simulator"
export PD_INI_DIR="/config/.config/Playdate Simulator"
mkdir -p "$PD_INI_DIR"
export PD_INI_FILE="$PD_INI_DIR/Playdate Simulator.ini"
echo "ShowPerfWarning=0" > $PD_INI_FILE
Expand All @@ -107,4 +94,6 @@ jobs:
- name: Run headless test
working-directory: ./tests
run: xvfb-run ../PlaydateSDK-*/bin/PlaydateSimulator tests.pdx
run: |
export HOME="/config"
xvfb-run ../PlaydateSDK-*/bin/PlaydateSimulator playdate_tests.pdx
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ src/tests/
pdex.bin
*.pdx
docs
tests/source/pdxinfo

# macOS general
.DS_Store
Expand Down Expand Up @@ -57,3 +58,11 @@ $RECYCLE.BIN/
tests/t_*
!tests/t_*.*
tests/playdate_tests

# IntelliJ IDEA
.idea
nimble.develop
nimble.paths

# Binaries
pdn
Loading

0 comments on commit cdfc645

Please sign in to comment.