Skip to content

Commit

Permalink
Merge pull request #2 from Anton-4/flake-and-ci-tests
Browse files Browse the repository at this point in the history
added flake + CI tests
  • Loading branch information
Anton-4 authored Jan 3, 2025
2 parents b49ff71 + 1c62736 commit bb66c31
Show file tree
Hide file tree
Showing 5 changed files with 299 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/tests_native.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/tests_nix.yml
Original file line number Diff line number Diff line change
@@ -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'
6 changes: 6 additions & 0 deletions CI/all_tests.sh
Original file line number Diff line number Diff line change
@@ -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
182 changes: 182 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
});
}

0 comments on commit bb66c31

Please sign in to comment.