diff --git a/.github/workflows/generate-docs.yaml b/.github/workflows/generate-docs.yaml new file mode 100644 index 0000000..8e91f4a --- /dev/null +++ b/.github/workflows/generate-docs.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..ada7642 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5653600..0039dc1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ examples/*.wasm *.png .envrc + +generated-docs/ + +format.sh \ No newline at end of file diff --git a/README.md b/README.md index 6a10e43..40c455e 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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`. diff --git a/ci/all_tests.sh b/ci/all_tests.sh new file mode 100644 index 0000000..f381d0a --- /dev/null +++ b/ci/all_tests.sh @@ -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 \ No newline at end of file