Skip to content

Commit

Permalink
add CI stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewilliamboswell committed Jan 8, 2024
1 parent c821753 commit abf73a3
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/generate-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Generate docs

on:
# Run when a release is published
release:
types:
- published

jobs:
generate-docs:
name: Generate docs
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- name: Check out the repository
uses: actions/checkout@v3
- name: Install Roc
uses: hasnep/setup-roc@main
with:
roc-version: nightly
- name: Generate docs
run: roc docs package/main.roc
- name: Fix absolute paths
run: |
find generated-docs/ -type f -name '*.html' -exec sed -i "s/\(href\|src\)=\"\//\1=\"\/${{ github.event.repository.name }}\//g" {} +
- name: Upload docs artifact
uses: actions/upload-pages-artifact@v1
with:
path: generated-docs
- name: Deploy docs
uses: actions/deploy-pages@v2
38 changes: 38 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
pull_request:
workflow_dispatch:

# this cancels workflows currently in progress if you start a new one
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:

test-examples:
runs-on: [ubuntu-20.04]
steps:
- uses: actions/checkout@v3

- name: get latest roc nightly
run: |
curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz
- name: rename nightly tar
run: mv $(ls | grep "roc_nightly.*tar\.gz") roc_nightly.tar.gz

- name: decompress the tar
run: tar -xzf roc_nightly.tar.gz

- run: rm roc_nightly.tar.gz

- name: simplify nightly folder name
run: mv roc_nightly* roc_nightly

- run: ./roc_nightly/roc version

- run: sudo apt install -y expect

- run: expect -v

- run: ./ci/all_tests.sh
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ examples/*.wasm
*.png

.envrc

generated-docs/

format.sh
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Roc platform for the [wasm4](https://wasm4.org) game engine.

The intent for this platform is to have some fun, learn more about Roc and platform development, and contribute something for others to enjoy.

*Work In Progress* we are still working on improving API, writing more examples, and including documentation. 🚧
🚧 *Work In Progress* 🚧 we are still working on improving API, writing more examples, and including documentation.

### Setup

Expand Down Expand Up @@ -32,6 +32,12 @@ The `build.zig` script reports any warnings or errors for the app using `roc che

![sound demo](/examples/sound.gif)

### Documentation

*TODO - add link to GH Pages site*

To generate platform docs locally use `roc docs platform/main.roc`, and then host the docs using a file server e.g. `simple-http-server generated-docs/`.

### Bundling a Game for Release

To release a game, first build it with optimizations by adding `-Doptimize=ReleaseSmall`.
Expand Down
34 changes: 34 additions & 0 deletions ci/all_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -euxo pipefail

if [ -z "${ROC}" ]; then
echo "ERROR: The ROC environment variable is not set.
Set it to something like:
/home/username/Downloads/roc_nightly-linux_x86_64-2023-10-30-cb00cfb/roc
or
/home/username/gitrepos/roc/target/build/release/roc" >&2

exit 1
fi

EXAMPLES_DIR='./examples/'
PLATFORM_DIR='./platform/'

# roc check
for roc_file in $EXAMPLES_DIR*.roc; do
$ROC check $roc_file
done

for roc_file in $PLATFORM_DIR*.roc; do
$ROC check $roc_file
done

# roc build
for roc_file in $EXAMPLES_DIR*.roc; do
$ROC build $roc_file --target=wasm32 --no-link
done

# test building docs website
$ROC docs platform/main.roc

0 comments on commit abf73a3

Please sign in to comment.