Update project setup (#183)

* Update project setup to use spago.

* Add license and repo info to spago.dhall

* Fix check.yaml

* Remove unused dependencies

* Remove --no-install from checks.yaml

* Minor cleanup

* Readd nix checks

* Migrate everything to spago & remove Makefile

* Split nix environment install from build in workflow

* Fix NIX_PATH

* Make build step of workflow build everything

* Fix github action

Co-authored-by: sigma-andex <sigma.andex@pm.me>
This commit is contained in:
Connor Prussin 2021-11-12 23:46:59 -08:00 committed by GitHub
parent 6ce52417f7
commit beb4621f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 133 additions and 1533 deletions

View File

@ -16,15 +16,18 @@ jobs:
uses: actions/checkout@v2
- name: Install nix
uses: cachix/install-nix-action@v12
uses: cachix/install-nix-action@v15
with:
nix_path: nixpkgs=channel:nixos-20.09
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Install environment
run: nix-shell
- name: Build
run: nix-shell --run 'make build'
run: nix-shell --run "build test"
- name: Test
run: nix-shell --run 'make test-code'
run: nix-shell --run check-code
Validate_Format:
runs-on: ubuntu-latest
@ -34,9 +37,12 @@ jobs:
uses: actions/checkout@v2
- name: Install nix
uses: cachix/install-nix-action@v12
uses: cachix/install-nix-action@v15
with:
nix_path: nixpkgs=channel:nixos-20.09
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Install environment
run: nix-shell
- name: Validate Format
run: nix-shell --run 'make test-format'
run: nix-shell --run check-format

9
.gitignore vendored
View File

@ -1,7 +1,4 @@
/out
/bower_components
/node_modules
/output
/.psa-stash
/.psci_modules
/.psc-ide-port
/.spago/
/generated-docs
/output

143
Makefile
View File

@ -1,143 +0,0 @@
# Configuration for Make
MAKEFLAGS += --warn-undefined-variables
.DEFAULT_GOAL := help
.PHONY: clean example format help repl test test-code test-format
.SILENT:
# Executables used in this makefile
PULP := pulp
NODE := node
YARN := yarn
BOWER := bower
PURSTIDY := purs-tidy
# Options to pass to pulp when building
BUILD_OPTIONS := -- --stash --censor-lib --strict
# Package manifest files
PACKAGEJSON := package.json
BOWERJSON = bower.json
# Various input directories
SRCPATH := ./src
TESTPATH := ./test
DOCS := ./docs
EXAMPLESPATH := $(DOCS)/Examples
EXAMPLEPATH := $(EXAMPLESPATH)/$(EXAMPLE)
# Various output directories
OUTPUT := ./out
MODULES := ./node_modules
BOWER_COMPONENTS := ./bower_components
BUILD := $(OUTPUT)/build
OUTPUT_DOCS := $(OUTPUT)/docs
OUTPUT_EXAMPLE := $(OUTPUT)/examples/$(EXAMPLE)
# The entry point for the compiled example, if an EXAMPLE is specified
EXAMPLE_INDEX := $(OUTPUT_EXAMPLE)/index.js
# Globs that match all source files
SOURCES := $(SRCPATH)/**/*
TESTSOURCES := $(TESTPATH)/**/*
EXAMPLESOURCES := $(EXAMPLESPATH)/**/*
# Install node modules
$(MODULES): $(PACKAGEJSON)
$(YARN) --cache-folder $(MODULES) install
# Install bower packages
$(BOWER_COMPONENTS): $(BOWERJSON) $(MODULES)
$(BOWER) install
# Build the source files
$(BUILD): $(BOWER_COMPONENTS) $(SOURCES) $(MODULES)
$(PULP) build \
--src-path $(SRCPATH) \
--build-path $(BUILD) \
$(BUILD_OPTIONS)
touch $(BUILD)
build: $(BUILD)
# Create the example output directory for the example in the environment
# variable EXAMPLE
$(OUTPUT_EXAMPLE):
mkdir -p $(OUTPUT_EXAMPLE)
# Build the example specified by the environment variable EXAMPLE
$(EXAMPLE_INDEX): $(OUTPUT_EXAMPLE) $(BUILD) $(EXAMPLEPATH)/Main.purs $(MODULES)
$(PULP) build \
--src-path $(EXAMPLEPATH) \
--include $(SRCPATH) \
--build-path $(BUILD) \
--main Examples.$(EXAMPLE).Main \
--to $(EXAMPLE_INDEX)
# Run the example specified by the environment variable EXAMPLE
ifeq ($(EXAMPLE),)
example:
$(info Which example would you like to run?)
$(info )
$(info Available examples:)
ls -1 $(EXAMPLESPATH) | cat -n
read -rp " > " out; \
out=$$(echo $$out | sed 's/[^0-9]*//g'); \
$(MAKE) example \
EXAMPLE=$$([ $$out ] && ls -1 $(EXAMPLESPATH) | sed "$${out}q;d")
else
example: $(BUILD) $(EXAMPLE_INDEX)
$(NODE) $(EXAMPLE_INDEX)
endif
format: $(MODULES) $(SOURCES) $(TESTSOURCES) $(EXAMPLESOURCES)
$(PURSTIDY) format-in-place $(SRCPATH) $(TESTPATH) $(EXAMPLESPATH)
test-format: $(MODULES) $(SOURCES) $(TESTSOURCES) $(EXAMPLESOURCES)
$(PURSTIDY) check $(SRCPATH) $(TESTPATH) $(EXAMPLESPATH)
# Run the test suite
test-code: $(BUILD) $(TESTSOURCES) $(EXAMPLESOURCES) $(MODULES)
$(PULP) test \
--src-path $(SRCPATH) \
--test-path $(TESTPATH) \
--include $(EXAMPLESPATH) \
--build-path $(BUILD) \
$(BUILD_OPTIONS)
test: test-code test-format
# Launch a repl with all modules loaded
repl: $(BOWER_COMPONENTS) $(SOURCES) $(TESTSOURCES) $(EXAMPLESOURCES) $(MODULES)
$(PULP) repl \
--include $(EXAMPLESPATH) \
--src-path $(SRCPATH) \
--test-path $(TESTPATH)
# Remove all make output from the source tree
clean:
rm -rf $(OUTPUT) $(MODULES) $(BOWER_COMPONENTS)
# Print out a description of all the supported tasks
help:
$(info HTTPure make utility)
$(info )
$(info Usage: make [ build | clean | docs | example | format | help | repl | test ])
$(info )
$(info - make build Build the documentation into $(OUTPUT_DOCS))
$(info - make clean Remove all build files)
$(info - make docs Build the documentation into $(OUTPUT_DOCS))
$(info - make example Run the example in environment variable EXAMPLE)
$(info - make format Run code formatting)
$(info - make help Print this help)
$(info - make repl Launch a repl with all project code loaded)
$(info - make test Run all checks)
$(info - make test-format Validate the code formatting)
$(info - make test-code Run the code test suite)
# Build the documentation
$(OUTPUT_DOCS): $(BOWER_COMPONENTS) $(SOURCES) $(MODULES)
$(PULP) docs \
--src-path $(SRCPATH) \
--build-path $(BUILD)
rm -rf $(OUTPUT_DOCS)
mv generated-docs $(OUTPUT_DOCS)
docs: $(OUTPUT_DOCS)

View File

@ -28,7 +28,7 @@ check our [contributing guide](./Contributing.md).
## Installation
```bash
psc-package install httpure
spago install httpure
```
## Quick Start

View File

@ -1,52 +0,0 @@
{
"name": "purescript-httpure",
"homepage": "https://github.com/cprussin/purescript-httpure",
"description": "A web framework written in PureScript.",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/cprussin/purescript-httpure"
},
"ignore": [
"**/.*",
"docs",
"out",
"test",
"Makefile",
"*.json",
"*.md"
],
"dependencies": {
"purescript-prelude": "^5.0.0",
"purescript-either": "^5.0.0",
"purescript-effect": "^3.0.0",
"purescript-aff": "^6.0.0",
"purescript-node-buffer": "^7.0.0",
"purescript-node-http": "^6.0.0",
"purescript-js-uri": "https://github.com/purescript-contrib/purescript-js-uri.git#^2.0.0",
"purescript-console": "^5.0.0",
"purescript-maybe": "^5.0.0",
"purescript-newtype": "^4.0.0",
"purescript-node-fs": "^6.0.0",
"purescript-node-streams": "^5.0.0",
"purescript-options": "^6.0.0",
"purescript-tuples": "^6.0.0",
"purescript-foldable-traversable": "^5.0.0",
"purescript-foreign": "^6.0.0",
"purescript-strings": "^5.0.0",
"purescript-type-equality": "^4.0.0",
"purescript-arrays": "^6.0.0",
"purescript-bifunctors": "^5.0.0",
"purescript-refs": "^5.0.0"
},
"devDependencies": {
"purescript-spec": "^5.0.0",
"purescript-node-fs-aff": "^7.0.0",
"purescript-node-child-process": "^7.0.0",
"purescript-psci-support": "^5.0.0",
"purescript-exceptions": "^5.0.0",
"purescript-lists": "^6.0.0",
"purescript-unsafe-coerce": "^5.0.0",
"purescript-control": "^5.0.0"
}
}

View File

@ -1,9 +0,0 @@
{
"private": true,
"devDependencies": {
"bower": "^1.8.12",
"pulp": "^15.0.0",
"purescript-psa": "^0.8.2",
"purs-tidy": "^0.6.2"
}
}

5
packages.dhall Normal file
View File

@ -0,0 +1,5 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.4-20211030/packages.dhall sha256:5cd7c5696feea3d3f84505d311348b9e90a76c4ce3684930a0ff29606d2d816c
in upstream

View File

@ -12,25 +12,69 @@ let
'';
};
};
pkgs-unstable = import sources.nixpkgs-unstable {};
purs-tidy-overlay = pkgs: _: {
inherit (import sources.easy-purescript-nix { inherit pkgs; }) purs-tidy;
};
unstable-packages-overlay = _: _: {
inherit (pkgs-unstable) purescript;
inherit (import sources.nixpkgs-unstable {}) purescript;
};
pkgs = import sources.nixpkgs {
overlays = [
niv-overlay
purs-tidy-overlay
unstable-packages-overlay
];
};
build = pkgs.writeShellScriptBin "build" ''
if [ "$1" == "test" ]
then
spago -x test.dhall build
else
spago build
fi
'';
check = pkgs.writeShellScriptBin "check" "check-format && check-code";
check-code = pkgs.writeShellScriptBin "check-code" "spago -x test.dhall test";
check-format = pkgs.writeShellScriptBin "check-format" "purs-tidy check src test docs";
clean = pkgs.writeShellScriptBin "clean" "rm -rf output .psci_modules .spago";
docs = pkgs.writeShellScriptBin "docs" "spago docs";
example = pkgs.writeShellScriptBin "example" ''
if [ "$1" ]
then
spago -x test.dhall run --main Examples.$1.Main
else
echo "Which example would you like to run?\n\nAvailable examples:"
ls -1 ./docs/Examples | cat -n
read -rp " > " out
if [ "$out" ]
then
$0 $(ls -1 ./docs/Examples | sed "''${out}q;d")
fi
fi
'';
format = pkgs.writeShellScriptBin "format" "purs-tidy format-in-place src test docs";
repl = pkgs.writeShellScriptBin "repl" "spago repl";
in
pkgs.mkShell {
buildInputs = [
pkgs.niv
pkgs.git
pkgs.niv
pkgs.nodePackages.bower
pkgs.nodePackages.pulp
pkgs.nodejs
pkgs.yarn
pkgs.purescript
pkgs.purs-tidy
pkgs.spago
build
check
check-code
check-format
clean
docs
example
format
repl
];
shellHook = "export PATH=$PATH:$PWD/node_modules/.bin";
}

View File

@ -1,14 +1,26 @@
{
"easy-purescript-nix": {
"branch": "master",
"description": "Easy PureScript (and other tools) with Nix",
"homepage": "",
"owner": "justinwoo",
"repo": "easy-purescript-nix",
"rev": "7802db65618c2ead3a55121355816b4c41d276d9",
"sha256": "0n99hxxcp9yc8yvx7bx4ac6askinfark7dnps3hzz5v9skrvq15q",
"type": "tarball",
"url": "https://github.com/justinwoo/easy-purescript-nix/archive/7802db65618c2ead3a55121355816b4c41d276d9.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "release-20.09",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1ac507ba981970c8e864624542e31eb1f4049751",
"sha256": "1r05lrkvmjhygpmxj4h0rmvz53c7zmy5lff5az09bi1nwqm1xr42",
"rev": "1c1f5649bb9c1b0d98637c8c365228f57126f361",
"sha256": "0f2nvdijyxfgl5kwyb4465pppd5vkhqxddx6v40k2s0z9jfhj0xl",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/1ac507ba981970c8e864624542e31eb1f4049751.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/1c1f5649bb9c1b0d98637c8c365228f57126f361.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs-unstable": {
@ -17,10 +29,10 @@
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5df05c902cde398e056eb6271d5fe13e418db4c6",
"sha256": "12plc7k251z1dmmrd29lyrpw0xmjvmf79yj568aapzrcki5mrw74",
"rev": "8f39ad3da14ce78daf249c8291a4e43a17bbcf98",
"sha256": "1sdfb6bq8n0v5m6962cz5nfw3hkcrlzc1xnw6b0xnkr3sxxj6m34",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5df05c902cde398e056eb6271d5fe13e418db4c6.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/8f39ad3da14ce78daf249c8291a4e43a17bbcf98.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

31
spago.dhall Normal file
View File

@ -0,0 +1,31 @@
{ name = "httpure"
, dependencies =
[ "aff"
, "arrays"
, "bifunctors"
, "console"
, "effect"
, "either"
, "foldable-traversable"
, "foreign-object"
, "js-uri"
, "maybe"
, "newtype"
, "node-buffer"
, "node-fs"
, "node-http"
, "node-streams"
, "options"
, "ordered-collections"
, "prelude"
, "psci-support"
, "refs"
, "strings"
, "tuples"
, "type-equality"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs" ]
, license = "MIT"
, repository = "https://github.com/cprussin/purescript-httpure.git"
}

14
test.dhall Normal file
View File

@ -0,0 +1,14 @@
let conf = ./spago.dhall
in conf // {
sources = conf.sources # [ "test/**/*.purs", "docs/Examples/**/*.purs" ],
dependencies = conf.dependencies # [
, "exceptions"
, "lists"
, "node-child-process"
, "node-fs-aff"
, "spec"
, "transformers"
, "unsafe-coerce"
]
}

1305
yarn.lock

File diff suppressed because it is too large Load Diff