Skip to content

Commit f5bcbc2

Browse files
committed
fix back
fix front and main flake add a common flake try flake-utils Revert "try flake-utils" This reverts commit b085080. add tools to back flake add common flake rm old files add common inputs update codium fix use common flake update flakes update flake inputs separate writing settings add nix merge builds install deps in ci try nix in ci update ci use nix only use ubuntu 22.04 try deploy back fix cp error echo back location try nix-shell fix typo add shell to back add cp add nix channel try build try-phi-back try nix develop with nixpkgs nix develop in separate step use default dir use nix shell add nix path use nix build try deploy from branch build front with nix add manual run add clear all other files try to clear branch keep .git prepare a folder use a helper folder trick heroku custom deploy to heroku try checkout a branch use env use branch name try push branch with -f ls branches checkout and name branch name branch checkout + heroku-deploy use reusable workflow add checkout add vscode extensions make an action try composite action make path add inputs rm env use prepare nix add extensions and settings add nix build
1 parent 64b628b commit f5bcbc2

33 files changed

+6764
-3589
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Prepare Nix
2+
3+
# Syntax
4+
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#about-yaml-syntax-for-github-actions
5+
6+
description: Install Nix, log in to cachix, cache flake inputs and shell
7+
8+
inputs:
9+
ROOT:
10+
description: a dir for which this action should be run
11+
required: true
12+
GITHUB_TOKEN:
13+
description: GitHub token
14+
required: true
15+
CACHE:
16+
description: cache name
17+
default: br4ch1st0chr0n3-nix-managed
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Install Nix
23+
uses: cachix/install-nix-action@v17
24+
with:
25+
extra_nix_config: |
26+
access-tokens = github.com=${{ inputs.GITHUB_TOKEN }}
27+
substituters = https://br4ch1st0chr0n3-nix-managed.cachix.org https://br4ch1st0chr0n3-flakes.cachix.org https://cache.nixos.org/ https://hydra.iohk.io https://nix-community.cachix.org
28+
trusted-public-keys = br4ch1st0chr0n3-nix-managed.cachix.org-1:sDKsfgu5fCCxNwVhZg+AWeGvbLlEtZoyzkSNKRM/KAo= br4ch1st0chr0n3-flakes.cachix.org-1:Dyc2yLlRIkdbq8CtfOe24QQhQVduQaezkyV8J9RhuZ8= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
29+
30+
# - uses: cachix/cachix-action@v10
31+
# with:
32+
# name: ${{ env.cache }}
33+
# authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
34+
# - name: Push inputs to cachix
35+
# run: |
36+
# # https://docs.cachix.org/pushing#flakes
37+
38+
# nix flake archive --json \
39+
# | jq -r '.path,(.inputs|to_entries[].value.path)' \
40+
# | cachix push ${{ matrix.cache }}
41+
# # shell: bash
42+
# - name: Push devshell to cachix
43+
# run: |
44+
# nix develop --profile dev-profile
45+
# cachix push ${{ matrix.cache }} dev-profile
46+
# # shell: bash

.github/workflows/back.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
front:
11+
strategy:
12+
matrix:
13+
os: [ubuntu-22.04]
14+
runs-on: ${{ matrix.os }}
15+
env:
16+
ROOT: front
17+
CACHE: br4ch1st0chr0n3-nix-managed
18+
ARTIFACTS_BRANCH: front-artifacts
19+
ARTIFACTS_DIR: artifacts
20+
steps:
21+
- name: Checkout main
22+
uses: actions/checkout@v3
23+
- name: Prepare Nix
24+
uses: ./.github/actions/prepare-nix
25+
with:
26+
ROOT: ${{ env.ROOT }}
27+
CACHE: ${{ env.CACHE }}
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Build with Nix
31+
run: |
32+
cd ${{ env.ROOT }}
33+
nix develop -c bash -c '
34+
npm run build:gh-pages
35+
'
36+
37+
- name: GitHub Pages action
38+
uses: peaceiris/[email protected]
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
publish_dir: ./front/docs
42+
force_orphan: true
43+
44+
back:
45+
strategy:
46+
matrix:
47+
os: [ubuntu-22.04]
48+
runs-on: ${{ matrix.os }}
49+
env:
50+
ROOT: back
51+
CACHE: br4ch1st0chr0n3-nix-managed
52+
ARTIFACTS_BRANCH: back-artifacts
53+
ARTIFACTS_DIR: artifacts
54+
APP_NAME: try-phi-back
55+
steps:
56+
- uses: actions/checkout@v3
57+
- name: Prepare Nix
58+
uses: ./.github/actions/prepare-nix
59+
with:
60+
ROOT: ${{ env.ROOT }}
61+
CACHE: ${{ env.CACHE }}
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Build with Nix
65+
run: |
66+
cd ${{ env.ROOT }}
67+
nix build
68+
69+
- name: Prepare ${{ env.ARTIFACTS_DIR }} dir
70+
run: |
71+
cd ${{ env.ROOT }}
72+
mkdir ${{ env.ARTIFACTS_DIR }}
73+
cp result/bin/back Procfile ${{ env.ARTIFACTS_DIR }}
74+
printf "%s" '{ "name": "appname", "version": "0.0.1", "dependencies": {} }' > ${{ env.ARTIFACTS_DIR }}/package.json
75+
76+
- name: Push ${{ env.ARTIFACTS_DIR }} dir to ${{ env.ARTIFACTS_BRANCH }}
77+
78+
env:
79+
REPO: self
80+
BRANCH: ${{ env.ARTIFACTS_BRANCH }}
81+
FOLDER: ${{ env.ROOT }}/${{ env.ARTIFACTS_DIR }}
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
84+
# Deploy to Heroku
85+
- name: Checkout ${{ env.ARTIFACTS_BRANCH }}
86+
uses: actions/checkout@v3
87+
with:
88+
ref: ${{ env.ARTIFACTS_BRANCH }}
89+
90+
- name: Push to Heroku
91+
uses: akhileshns/[email protected]
92+
with:
93+
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
94+
heroku_app_name: ${{ env.APP_NAME }}
95+
heroku_email: ${{ secrets.HEROKU_EMAIL }}
96+
branch: ${{ env.ARTIFACTS_BRANCH }}

.github/workflows/front.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.direnv
33
result
44
node_modules
5-
.parcel-cache
5+
.parcel-cache
6+
dev-profile*

.vscode/settings.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
{
2-
"haskell.serverExecutablePath": "haskell-language-server",
3-
"todo-tree.regex.regex": "((--\\s*($TAGS))|\\{-\\s($TAGS).*(\\n.*)*-})",
2+
"editor.formatOnSave": true,
3+
"files.autoSave": "afterDelay",
4+
"files.refactoring.autoSave": true,
45
"files.watcherExclude": {
56
"**/.spago/**": true
67
},
8+
"git.autofetch": true,
9+
"gitlens.codeLens.authors.enabled": false,
10+
"gitlens.codeLens.enabled": false,
11+
"gitlens.codeLens.recentChange.enabled": false,
12+
"gitlens.currentLine.enabled": false,
13+
"gitlens.currentLine.pullRequests.enabled": false,
14+
"gitlens.hovers.currentLine.over": "line",
15+
"gitlens.hovers.enabled": false,
16+
"gitlens.statusBar.enabled": false,
17+
"haskell.manageHLS": "PATH",
18+
"haskell.serverExecutablePath": "haskell-language-server",
19+
"nix.enableLanguageServer": true,
20+
"nix.serverPath": "rnix-lsp",
21+
"purescript.formatter": "purs-tidy",
722
"purescript.outputDirectory": "./front/output/",
823
"purescript.packagePath": "./front",
924
"purescript.sourcePath": "./front/src",
10-
"vscode-dhall-lsp-server.executable": "dhall-lsp-server"
11-
}
25+
"todo-tree.regex.regex": "((--\\s*($TAGS))|\\{-\\s($TAGS).*(\\n.*)*-})",
26+
"vscode-dhall-lsp-server.executable": "dhall-lsp-server",
27+
"workbench.colorTheme": "Monokai",
28+
"workbench.sideBar.location": "right",
29+
"yaml.schemas": {
30+
"https://json.schemastore.org/github-action": "./.githhub/actions/**/action.yml",
31+
"https://json.schemastore.org/github-workflow": "./.githhub/workflows/**/*.yml"
32+
}
33+
}

.vscode/tasks.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@
4545
"type": "shell",
4646
"label": "haskell watch",
4747
"command": "stack build --test --no-run-tests --file-watch"
48+
},
49+
{
50+
"label": "Client run",
51+
"command": "nix",
52+
"args": ["develop", ".#front"],
53+
"options": {
54+
"cwd": "${workspaceFolder}"
55+
}
56+
},
57+
{
58+
"label": "Server run",
59+
"command": "nix",
60+
"args": ["develop", ".#back"],
61+
"options": {
62+
"cwd": "${workspaceFolder}"
63+
}
64+
},
65+
{
66+
"label": "Start app",
67+
"dependsOn": ["Client run", "Server run"]
4868
}
4969
]
5070
}

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ It is combined with [EO](https://github.com/objectionary/eo) editor. EO is based
2121
- [EO editor](https://github.com/br4ch1st0chr0n3/eo-editor)
2222
- [Phi editor](https://github.com/br4ch1st0chr0n3/phi-editor)
2323

24-
## Prerequisits
24+
## Prerequisites
2525

2626
- Install [Nix](https://nixos.org/download.html) (Single-user installation)
2727
```sh
2828
sh <(curl -L https://nixos.org/nix/install) --no-daemon
2929
```
3030

31+
- Enable [flakes](https://nixos.wiki/wiki/Flakes#Permanent)
32+
3133
- Enter the repo
3234
```sh
3335
git clone https://github.com/objectionary/try-phi
@@ -36,7 +38,7 @@ It is combined with [EO](https://github.com/objectionary/eo) editor. EO is based
3638

3739
## Quick start
3840

39-
- Run back and front in separate tereminals
41+
- Run back and front in separate terminals
4042
```console
4143
nix develop .#back
4244
nix develop .#front
@@ -46,35 +48,35 @@ It is combined with [EO](https://github.com/objectionary/eo) editor. EO is based
4648

4749
- Install [direnv](https://nix.dev/tutorials/declarative-and-reproducible-developer-environments#direnv-automatically-activating-the-environment-on-directory-change) - steps 1, 2
4850

49-
- For [VS Code](https://code.visualstudio.com/)
50-
- Install extensions
51+
- Allow direnv in flake folders
5152
```sh
52-
code --install-extension mkhl.direnv --install-extension haskell.haskell --install-extension nwolverson.ide-purescript
53+
direnv allow
54+
(cd front && direnv allow)
55+
(cd back && direnv allow && stack build)
56+
```
57+
58+
- Open Codium
59+
```console
60+
nix develop .#codium
61+
codium .
5362
```
54-
- Open workspace in `.vscode/try-phi.code-workspace`
5563

5664
- In separate terminals:
5765
- backend dev
5866
```sh
5967
cd back
60-
# for the first time
61-
direnv allow
62-
# build for HLS
63-
nix build
64-
# start the server
6568
nix run
6669
```
6770
- front
6871
```sh
6972
cd front
70-
# for the first time
7173
direnv allow
72-
# open app in a browser
7374
npm run dev
7475
```
7576
- Or run any other command from [package.json](package.json)
7677

77-
- If in VS Code, reload the window (`Ctrl`+`Shift`+`P` -> `Developer: Reload window`) and repeat previous commands to start the server and the client
78+
- In case of problems reload the window (`Ctrl`+`Shift`+`P` -> `Developer: Reload window`) and repeat previous commands to start the server and the client
79+
80+
<!-- TODO https://code.visualstudio.com/docs/editor/tasks#_compound-tasks
7881

79-
- For Haskell, your shell will have [haskell-language-server](https://github.com/haskell/haskell-language-server)
80-
- For Purescript - [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
82+
start server and client in different terminals -->

back/.gitmodules

Whitespace-only changes.

0 commit comments

Comments
 (0)