diff --git a/.github/workflows/tests_native.yml b/.github/workflows/tests_native.yml new file mode 100644 index 0000000..6163331 --- /dev/null +++ b/.github/workflows/tests_native.yml @@ -0,0 +1,46 @@ +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: + + run-tests: + runs-on: [ubuntu-22.04] + steps: + - uses: actions/checkout@v3 + + # get roc cli + - id: try_fetching_testing_release + continue-on-error: true + run: | + curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-TESTING.tar.gz + + - name: There are no TESTING releases, checking regular releases instead + if: steps.try_fetching_testing_release.outcome == 'failure' + 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 + + - name: Add roc_nightly to PATH + run: echo "${{ github.workspace }}/roc_nightly" >> $GITHUB_PATH + + - run: roc version + + # run all tests + - name: Run tests + run: ./CI/all_tests.sh \ No newline at end of file diff --git a/.github/workflows/tests_nix.yml b/.github/workflows/tests_nix.yml new file mode 100644 index 0000000..564be7e --- /dev/null +++ b/.github/workflows/tests_nix.yml @@ -0,0 +1,26 @@ +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: + run-tests-nix: + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + + # install nix + - uses: cachix/install-nix-action@v23 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Run tests + run: nix develop -c sh -c './CI/all_tests.sh' \ No newline at end of file diff --git a/CI/all_tests.sh b/CI/all_tests.sh new file mode 100755 index 0000000..33e79b7 --- /dev/null +++ b/CI/all_tests.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +set -exo pipefail + +roc check main.roc \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ef4af2b --- /dev/null +++ b/flake.lock @@ -0,0 +1,182 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1732722421, + "narHash": "sha256-HRJ/18p+WoXpWJkcdsk9St5ZiukCqSDgbOGFa8Okehg=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9ed2ac151eada2306ca8c418ebd97807bb08f6ac", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixgl": { + "inputs": { + "flake-utils": [ + "roc", + "flake-utils" + ], + "nixpkgs": [ + "roc", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713543440, + "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", + "owner": "guibou", + "repo": "nixGL", + "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "type": "github" + }, + "original": { + "owner": "guibou", + "repo": "nixGL", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1722403750, + "narHash": "sha256-tRmn6UiFAPX0m9G1AVcEPjWEOc9BtGsxGcs7Bz3MpsM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "184957277e885c06a505db112b35dfbec7c60494", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "184957277e885c06a505db112b35dfbec7c60494", + "type": "github" + } + }, + "roc": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils_2", + "nixgl": "nixgl", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1735910140, + "narHash": "sha256-v1/8HGe29QO0M9SfZruAMvHgWgm3SJPg7GFEVrXzEPM=", + "owner": "roc-lang", + "repo": "roc", + "rev": "2263d8821a213629ee62193cdf56af9a2796c1c1", + "type": "github" + }, + "original": { + "owner": "roc-lang", + "repo": "roc", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "roc", + "nixpkgs" + ], + "roc": "roc" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "roc", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1732802692, + "narHash": "sha256-kFrxb45qj52TT/OFUFyTdmvXkn/KXDUL0/DOtjHEQvs=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "34971069ec33755b2adf2481851f66d8ec9a6bfa", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5babc57 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "roc agent devShell flake"; + + inputs = { + roc.url = "github:roc-lang/roc"; + nixpkgs.follows = "roc/nixpkgs"; + + # to easily make configs for multiple architectures + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, roc }: + let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; + in flake-utils.lib.eachSystem supportedSystems (system: + let + pkgs = import nixpkgs { inherit system; }; + rocPkgs = roc.packages.${system}; + + linuxInputs = with pkgs; + lib.optionals stdenv.isLinux [ + ]; + + darwinInputs = with pkgs; + lib.optionals stdenv.isDarwin + (with pkgs.darwin.apple_sdk.frameworks; [ + ]); + + sharedInputs = (with pkgs; [ + rocPkgs.cli + ]); + in { + + devShell = pkgs.mkShell { + buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs; + }; + + formatter = pkgs.nixpkgs-fmt; + }); +}