Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring elm branch up-to-date with master to fix ihp-new for elm #40

Merged
merged 58 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
810f62b
feat: add devenv support
pauldub Apr 21, 2023
318132b
Merge pull request #23 from pauldub/feat-devenv-support
mpscholten Apr 29, 2023
c01a2c8
Disabled ihp.projectPath
mpscholten Apr 29, 2023
78b14e5
Updated devenv config
mpscholten Apr 29, 2023
e812c00
Fixed indentation and added more default optiosn to devenv boilerplate
mpscholten Jun 3, 2023
43d3f58
Added devenv.sh specific rules
mpscholten Jun 3, 2023
eb174e3
Enabled nix flakes
mpscholten Jun 4, 2023
93dce5f
Added .envrc
mpscholten Jun 4, 2023
10de5a2
Added binary cache
mpscholten Jun 4, 2023
01f28f2
fixed build
mpscholten Jun 4, 2023
eeb86b4
Added comments
mpscholten Jun 4, 2023
eebbda8
Improved b.c. support for nix-build
mpscholten Jun 4, 2023
0e4f443
Added support for .env files
mpscholten Jun 4, 2023
cfeb08f
Added nixos comment
mpscholten Jun 4, 2023
31798eb
Added .env to .gitignore
mpscholten Jun 4, 2023
ec32ade
Merge pull request #24 from digitallyinduced/flakes
mpscholten Jun 5, 2023
c504908
Added comment on .env file
mpscholten Jun 5, 2023
9639252
Delete devenv.yaml
mpscholten Jun 5, 2023
177a78a
Added flake.lock
mpscholten Jun 5, 2023
d546ef6
Use latest IHP version
mpscholten Jun 5, 2023
70f446a
updated ihp
mpscholten Jun 5, 2023
7a3888c
use newest flake-compat version in default.nix
Eisfunke Jun 7, 2023
ff63ce4
update flake for new IHP flakeModule
Eisfunke Jun 7, 2023
56667c9
restructure flake to use inputs follows
Eisfunke Jun 13, 2023
6c22941
refactor inputs
Eisfunke Jun 20, 2023
cda3d4f
add devenv input following IHP
Eisfunke Jun 20, 2023
d0b7603
Skip yes questions on first direnv run caused by nix flake config
mpscholten Jun 24, 2023
dcca577
add default haskellPackages to flake template
Eisfunke Jul 4, 2023
13a8c4e
Merge pull request #25 from digitallyinduced/nicolas/flake
mpscholten Jul 13, 2023
2b2ae12
use latest ihp master
mpscholten Jul 13, 2023
28439b0
Updated flake.lock
mpscholten Jul 14, 2023
273ca96
updated to latest ihp master
mpscholten Jul 15, 2023
4bd7161
Updated boilerplate to use the new IHP_LIB env var
mpscholten Jul 17, 2023
4bee32b
Fixed HLS not working due to missing build/ihp-lib
mpscholten Jul 17, 2023
4152a90
remove lock file
Eisfunke Jul 18, 2023
6e54036
Merge pull request #29 from digitallyinduced/nicolas/remove-lock-file
mpscholten Jul 19, 2023
8f42f18
Use IHP v1.1 branch
mpscholten Jul 21, 2023
83f69ba
Updated start script for IHP v1.1
mpscholten Jul 21, 2023
fb88f6f
Readded flake.lock
mpscholten Jul 21, 2023
832d1a5
Updated to the right commit
mpscholten Jul 21, 2023
07e71a1
Removed hlint as a default dependency
mpscholten Oct 3, 2023
7036eaa
Updated to IHP v1.2.0
mpscholten Nov 15, 2023
d8dc79c
Add more defaults an docs to flake.nix (#30)
amitaibu Feb 21, 2024
44cdcd3
Declare nixpkgs (#31)
amitaibu Feb 22, 2024
d8b89b2
Add config with placeholder for logging to AWS CloudWatch (#32)
amitaibu Feb 27, 2024
73df841
Add IHP_SESSION_SECRET placeholder (#33)
amitaibu Feb 27, 2024
323591d
custom db url -right way (#34)
AronNovak Mar 11, 2024
68eb3de
Updated to IHP v1.3
mpscholten May 4, 2024
7f57e16
Added appName option
mpscholten Aug 1, 2024
c429ad8
test and deploy using github actions
AronNovak Aug 5, 2024
54adb52
initial README
AronNovak Aug 5, 2024
e34e3c3
adapt wording
AronNovak Aug 5, 2024
993b080
Merge pull request #36 from AronNovak/autodeploy-test
mpscholten Aug 5, 2024
9619680
disk space issue workaround
AronNovak Aug 6, 2024
7fcf4a5
Merge pull request #37 from AronNovak/disk-space-issue
mpscholten Aug 6, 2024
bb89c61
Fix deploy condition at GH actions Deploy job (#38)
AronNovak Aug 8, 2024
bcc02cd
Merge branch 'master' into elm
james64 Dec 18, 2024
bd0424b
Build elm files
james64 Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
fi

use flake . --impure --accept-flake-config

# Include .env file if it exists locally. Use the .env file to load env vars that you don't want to commit to git
if [ -f .env ]
then
set -o allexport
source .env
set +o allexport
fi
# Add your env vars here
#
# E.g. export AWS_ACCESS_KEY_ID="XXXXX"

# SMTP config for local development.
export SMTP_HOST="127.0.0.1" # On some computers may need `127.0.1.1` instead.
export SMTP_PORT="1025"
export SMTP_ENCRYPTION="Unencrypted"
6 changes: 3 additions & 3 deletions .ghci
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:set -XNoImplicitPrelude
:def source readFile
:source build/ihp-lib/applicationGhciConfig
import IHP.Prelude
:def loadFromIHP \file -> (System.Environment.getEnv "IHP_LIB") >>= (\ihpLib -> readFile (ihpLib <> "/" <> file))
:loadFromIHP applicationGhciConfig
import IHP.Prelude
95 changes: 95 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Test and Deploy

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
ENV: "qa"
PROJECT_NAME: myproject
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
NIXPKGS: "https://github.com/NixOS/nixpkgs/archive/51bcdc4cdaac48535dabf0ad4642a66774c609ed.tar.gz"

jobs:
tests:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=${{ env.NIXPKGS}}

# Use the cachix cache for faster builds.
- name: Cachix Init
uses: cachix/cachix-action@v15
with:
name: digitallyinduced
skipPush: true

# Install direnv, which also `direnv allow`s the project.
- uses: HatsuneMiku3939/[email protected]
with:
direnvVersion: 2.32.3

- name: Run project and tests
run: |
# @see https://github.com/actions/runner-images/issues/2840#issuecomment-1284059930
# IHP - NixOS requires a lots of disk space.
# Larger projects could easily run into unexpected failures.
sudo rm -rf /usr/share/dotnet
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
# Build generated files.
nix-shell --run "make build/Generated/Types.hs"
# Start the project in the background.
nix-shell --run "devenv up &"
# Execute the tests.
nix-shell --run "runghc $(make print-ghc-extensions) -i. -ibuild -iConfig Test/Main.hs"
deploy:
name: Deploy
needs: tests
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ env.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ env.SSH_HOST }} >> ~/.ssh/known_hosts
echo -e "Host ${{ env.PROJECT_NAME}}-${{ env.ENV }}\n HostName ${{ env.SSH_HOST }}\n User ${{ env.SSH_USER }}\n IdentityFile ~/.ssh/id_rsa" > ~/.ssh/config
chmod 600 ~/.ssh/config
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=${{ env.NIXPKGS}}

- name: Cachix Init
uses: cachix/cachix-action@v12
with:
name: digitallyinduced
skipPush: true

- uses: HatsuneMiku3939/direnv-action@v1
with:
direnvVersion: 2.32.3

- name: Deploy
run: |
deploy-to-nixos ${{ env.PROJECT_NAME}}-${{ env.ENV }}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.DS_Store
.envrc
.idea
.env
tmp
result
node_modules
Expand All @@ -23,3 +23,8 @@ elm-stuff
static/elm
# Ignore locally checked out IHP version
IHP

# devenv.sh
.devenv*
devenv.local.nix
.direnv
14 changes: 0 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
ifneq ($(wildcard IHP/.*),)
IHP = IHP/lib/IHP
else
ifneq ($(wildcard build/ihp-lib),)
IHP = build/ihp-lib
else
ifneq ($(shell which RunDevServer),)
IHP = $(shell dirname $$(which RunDevServer))/../lib/IHP
else
IHP = $(error IHP not found! Run the following command to fix this: nix-shell --run 'make .envrc' )
endif
endif
endif

CSS_FILES += ${IHP}/static/vendor/bootstrap.min.css
CSS_FILES += ${IHP}/static/vendor/flatpickr.min.css
CSS_FILES += static/app.css
Expand Down
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# IHP Project

This is an IHP (Integrated Haskell Platform) project with GitHub Actions for testing and deployment. For more information about IHP, see the [IHP Documentation](https://ihp.digitallyinduced.com/Guide/).

## GitHub Actions Workflow

This project includes a GitHub Actions workflow for automated testing and deployment. The workflow is defined in `.github/workflows/test.yml`.

### Workflow Triggers

The workflow is triggered on:
- Push to the `main` branch
- Pull requests to the `main` branch
- Manual trigger from the GitHub Actions tab

### Testing

The testing job performs the following steps:
1. Checks out the code
2. Sets up Nix
3. Initializes Cachix for faster builds
4. Installs and allows direnv
5. Builds generated files
6. Starts the project in the background
7. Runs the tests

### Deployment

For deployment, follow the [IHP Deployment Guide](https://ihp.digitallyinduced.com/Guide/deployment.html#deploying-with-deploytonixos) to set up a proper NixOS server for your project.

The deployment job runs after successful tests and only for the `main` branch. It performs the following steps:
1. Checks out the code
2. Sets up SSH for deployment
3. Sets up Nix
4. Initializes Cachix
5. Sets up direnv
6. Deploys to a NixOS server

## Setup Instructions

To use the GitHub Actions workflow in this project:

1. Set up the following secrets in your GitHub [repository settings](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions):
- `SSH_HOST`: The hostname or IP address of your deployment server
- `SSH_USER`: The username for SSH access to the deployment server
- `SSH_PRIVATE_KEY`: The private SSH key for authentication

2. Modify the `env` section in `.github/workflows/test.yml` if needed:
- Update `PROJECT_NAME` to match your project
- Adjust `ENV` if you want to use a different environment name
- Update `NIXPKGS` if you want to use a different Nixpkgs version

3. Ensure your project has the necessary test files in the `Test` directory.

4. If your deployment process differs, modify the `deploy` job in the workflow file accordingly.

5. Push your changes to the `main` branch to trigger the workflow.

## Manual Workflow Trigger

You can manually trigger the workflow from the Actions tab in your GitHub repository. This is useful for running tests or deploying without pushing changes.

## Customization

Feel free to customize the workflow file to fit your specific project needs. You may want to add additional steps, change the deployment process, or modify the testing procedure.

## Support

For issues related to IHP or this project's setup, please refer to the [IHP documentation](https://ihp.digitallyinduced.com/Guide/) or seek help on the [IHP Forum](https://ihp.digitallyinduced.com/community/).

For project-specific issues, please open an issue in this repository.
33 changes: 9 additions & 24 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
let
ihp = builtins.fetchGit {
url = "https://github.com/digitallyinduced/ihp.git";
ref = "refs/tags/v1.0.1";
};
haskellEnv = import "${ihp}/NixSupport/default.nix" {
ihp = ihp;
haskellDeps = p: with p; [
cabal-install
base
wai
text
hlint
p.ihp
];
otherDeps = p: with p; [
# Native dependencies, e.g. imagemagick
nodejs
elmPackages.elm
];
projectPath = ./.;
};
in
haskellEnv
# For backwards compatibility using flake.nix
(import
(
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/35bb57c0c8d8b62bbfd284272c928ceb64ddbde9.tar.gz";
sha256 = "sha256:1prd9b1xx8c0sfwnyzkspplh30m613j42l1k789s521f4kv4c2z2";
}
)
{ src = ./.; }).defaultNix
Loading