Skip to content

Commit

Permalink
fix back
Browse files Browse the repository at this point in the history
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
  • Loading branch information
deemp committed Sep 17, 2022
1 parent 64b628b commit f5bcbc2
Show file tree
Hide file tree
Showing 33 changed files with 6,764 additions and 3,589 deletions.
46 changes: 46 additions & 0 deletions .github/actions/prepare-nix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Prepare Nix

# Syntax
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#about-yaml-syntax-for-github-actions

description: Install Nix, log in to cachix, cache flake inputs and shell

inputs:
ROOT:
description: a dir for which this action should be run
required: true
GITHUB_TOKEN:
description: GitHub token
required: true
CACHE:
description: cache name
default: br4ch1st0chr0n3-nix-managed

runs:
using: composite
steps:
- name: Install Nix
uses: cachix/install-nix-action@v17
with:
extra_nix_config: |
access-tokens = github.com=${{ inputs.GITHUB_TOKEN }}
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
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=
# - uses: cachix/cachix-action@v10
# with:
# name: ${{ env.cache }}
# authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
# - name: Push inputs to cachix
# run: |
# # https://docs.cachix.org/pushing#flakes

# nix flake archive --json \
# | jq -r '.path,(.inputs|to_entries[].value.path)' \
# | cachix push ${{ matrix.cache }}
# # shell: bash
# - name: Push devshell to cachix
# run: |
# nix develop --profile dev-profile
# cachix push ${{ matrix.cache }} dev-profile
# # shell: bash
18 changes: 0 additions & 18 deletions .github/workflows/back.yml

This file was deleted.

96 changes: 96 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: CI

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
front:
strategy:
matrix:
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
env:
ROOT: front
CACHE: br4ch1st0chr0n3-nix-managed
ARTIFACTS_BRANCH: front-artifacts
ARTIFACTS_DIR: artifacts
steps:
- name: Checkout main
uses: actions/checkout@v3
- name: Prepare Nix
uses: ./.github/actions/prepare-nix
with:
ROOT: ${{ env.ROOT }}
CACHE: ${{ env.CACHE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build with Nix
run: |
cd ${{ env.ROOT }}
nix develop -c bash -c '
npm run build:gh-pages
'
- name: GitHub Pages action
uses: peaceiris/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./front/docs
force_orphan: true

back:
strategy:
matrix:
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
env:
ROOT: back
CACHE: br4ch1st0chr0n3-nix-managed
ARTIFACTS_BRANCH: back-artifacts
ARTIFACTS_DIR: artifacts
APP_NAME: try-phi-back
steps:
- uses: actions/checkout@v3
- name: Prepare Nix
uses: ./.github/actions/prepare-nix
with:
ROOT: ${{ env.ROOT }}
CACHE: ${{ env.CACHE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Build with Nix
run: |
cd ${{ env.ROOT }}
nix build
- name: Prepare ${{ env.ARTIFACTS_DIR }} dir
run: |
cd ${{ env.ROOT }}
mkdir ${{ env.ARTIFACTS_DIR }}
cp result/bin/back Procfile ${{ env.ARTIFACTS_DIR }}
printf "%s" '{ "name": "appname", "version": "0.0.1", "dependencies": {} }' > ${{ env.ARTIFACTS_DIR }}/package.json
- name: Push ${{ env.ARTIFACTS_DIR }} dir to ${{ env.ARTIFACTS_BRANCH }}
uses: s0/[email protected]
env:
REPO: self
BRANCH: ${{ env.ARTIFACTS_BRANCH }}
FOLDER: ${{ env.ROOT }}/${{ env.ARTIFACTS_DIR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Deploy to Heroku
- name: Checkout ${{ env.ARTIFACTS_BRANCH }}
uses: actions/checkout@v3
with:
ref: ${{ env.ARTIFACTS_BRANCH }}

- name: Push to Heroku
uses: akhileshns/[email protected]
with:
heroku_api_key: ${{ secrets.HEROKU_API_KEY }}
heroku_app_name: ${{ env.APP_NAME }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}
branch: ${{ env.ARTIFACTS_BRANCH }}
56 changes: 0 additions & 56 deletions .github/workflows/front.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.direnv
result
node_modules
.parcel-cache
.parcel-cache
dev-profile*
30 changes: 26 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
{
"haskell.serverExecutablePath": "haskell-language-server",
"todo-tree.regex.regex": "((--\\s*($TAGS))|\\{-\\s($TAGS).*(\\n.*)*-})",
"editor.formatOnSave": true,
"files.autoSave": "afterDelay",
"files.refactoring.autoSave": true,
"files.watcherExclude": {
"**/.spago/**": true
},
"git.autofetch": true,
"gitlens.codeLens.authors.enabled": false,
"gitlens.codeLens.enabled": false,
"gitlens.codeLens.recentChange.enabled": false,
"gitlens.currentLine.enabled": false,
"gitlens.currentLine.pullRequests.enabled": false,
"gitlens.hovers.currentLine.over": "line",
"gitlens.hovers.enabled": false,
"gitlens.statusBar.enabled": false,
"haskell.manageHLS": "PATH",
"haskell.serverExecutablePath": "haskell-language-server",
"nix.enableLanguageServer": true,
"nix.serverPath": "rnix-lsp",
"purescript.formatter": "purs-tidy",
"purescript.outputDirectory": "./front/output/",
"purescript.packagePath": "./front",
"purescript.sourcePath": "./front/src",
"vscode-dhall-lsp-server.executable": "dhall-lsp-server"
}
"todo-tree.regex.regex": "((--\\s*($TAGS))|\\{-\\s($TAGS).*(\\n.*)*-})",
"vscode-dhall-lsp-server.executable": "dhall-lsp-server",
"workbench.colorTheme": "Monokai",
"workbench.sideBar.location": "right",
"yaml.schemas": {
"https://json.schemastore.org/github-action": "./.githhub/actions/**/action.yml",
"https://json.schemastore.org/github-workflow": "./.githhub/workflows/**/*.yml"
}
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@
"type": "shell",
"label": "haskell watch",
"command": "stack build --test --no-run-tests --file-watch"
},
{
"label": "Client run",
"command": "nix",
"args": ["develop", ".#front"],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "Server run",
"command": "nix",
"args": ["develop", ".#back"],
"options": {
"cwd": "${workspaceFolder}"
}
},
{
"label": "Start app",
"dependsOn": ["Client run", "Server run"]
}
]
}
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ It is combined with [EO](https://github.com/objectionary/eo) editor. EO is based
- [EO editor](https://github.com/br4ch1st0chr0n3/eo-editor)
- [Phi editor](https://github.com/br4ch1st0chr0n3/phi-editor)

## Prerequisits
## Prerequisites

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

- Enable [flakes](https://nixos.wiki/wiki/Flakes#Permanent)

- Enter the repo
```sh
git clone https://github.com/objectionary/try-phi
Expand All @@ -36,7 +38,7 @@ It is combined with [EO](https://github.com/objectionary/eo) editor. EO is based

## Quick start

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

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

- For [VS Code](https://code.visualstudio.com/)
- Install extensions
- Allow direnv in flake folders
```sh
code --install-extension mkhl.direnv --install-extension haskell.haskell --install-extension nwolverson.ide-purescript
direnv allow
(cd front && direnv allow)
(cd back && direnv allow && stack build)
```

- Open Codium
```console
nix develop .#codium
codium .
```
- Open workspace in `.vscode/try-phi.code-workspace`

- In separate terminals:
- backend dev
```sh
cd back
# for the first time
direnv allow
# build for HLS
nix build
# start the server
nix run
```
- front
```sh
cd front
# for the first time
direnv allow
# open app in a browser
npm run dev
```
- Or run any other command from [package.json](package.json)

- If in VS Code, reload the window (`Ctrl`+`Shift`+`P` -> `Developer: Reload window`) and repeat previous commands to start the server and the client
- In case of problems reload the window (`Ctrl`+`Shift`+`P` -> `Developer: Reload window`) and repeat previous commands to start the server and the client

<!-- TODO https://code.visualstudio.com/docs/editor/tasks#_compound-tasks

- For Haskell, your shell will have [haskell-language-server](https://github.com/haskell/haskell-language-server)
- For Purescript - [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
start server and client in different terminals -->
Empty file removed back/.gitmodules
Empty file.
Loading

0 comments on commit f5bcbc2

Please sign in to comment.