Skip to content

Commit a41e37c

Browse files
authored
Merge pull request #125 from clue-labs/make
Add Makefile with build instructions
2 parents a916fbd + 1f1d38e commit a41e37c

5 files changed

Lines changed: 65 additions & 40 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
with:
1818
php-version: ${{ matrix.php }}
1919
coverage: none
20-
- run: composer install
21-
- run: vendor/bin/sculpin generate
22-
- run: docker run -d -p 8080:80 -v "$PWD"/build:/var/www/html php:7.4-apache sh -c "ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
23-
- run: tests/acceptance.sh http://localhost:8080
20+
- run: make
21+
- run: make served
22+
- run: make test

.github/workflows/diff.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@ jobs:
2020
with:
2121
php-version: ${{ matrix.php }}
2222
coverage: none
23-
- run: composer install
24-
- run: vendor/bin/sculpin generate --output-dir=old
23+
- run: test -f Makefile || echo -en "build:\n\tcomposer install\n\tvendor/bin/sculpin generate\n" > Makefile # remove me once Makefile is merged
24+
- run: make && mv build/ old/
2525

2626
# check out head ref and build site into new/
2727
- uses: actions/checkout@v3
2828
with:
2929
ref: ${{ github.event.pull_request.head.sha }}
3030
clean: false # Prevent removing files in old/
31-
- run: composer install
32-
- run: vendor/bin/sculpin generate --output-dir=new
31+
- run: make && mv build/ new/
3332

34-
# Diff between old and new
35-
- name: Diff between old and new
33+
# Diff between old/ and new/
34+
- name: Diff between old/ and new/
3635
run: |
37-
git diff --no-index --stat --color=always old new && echo No changed detected || true
38-
diff -r -u --color=always old new || true
36+
git diff --no-index --stat --color=always old/ new/ && echo No changed detected || true
37+
diff -r -u --color=always old/ new/ || true

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
build: vendor
2+
vendor/bin/sculpin generate
3+
4+
vendor: composer.json composer.lock
5+
composer install
6+
touch $@
7+
8+
serve: build
9+
docker run -it --rm -p 80:80 -v "$$PWD"/build/:/var/www/html/ php:8.1-apache sh -c "ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
10+
11+
served: build
12+
docker run -d --rm -p 80:80 -v "$$PWD"/build/:/var/www/html/ php:8.1-apache sh -c "ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
13+
@sleep 2
14+
@echo Container running. Use \"docker rm -f {containerId}\" to stop container.
15+
16+
test:
17+
bash tests/acceptance.sh
18+
19+
clean:
20+
rm -rf build/ vendor/
21+
22+
.PHONY: build serve served test clean

README.md

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,55 @@
11
# clue.engineering
22

3-
Source code for https://clue.engineering/
3+
Source code for the https://clue.engineering/ website.
44

5-
## Install
5+
## Build
66

7-
Install dependencies:
7+
You can build the website like this:
88

99
```bash
10-
composer install
10+
make
1111
```
1212

13-
Build website:
13+
Once built, you can manually browse the `build/` directory or run the web server
14+
container (Apache) in the foreground like this:
1415

1516
```bash
16-
vendor/bin/sculpin generate
17+
make serve
1718
```
1819

19-
This will create a `build/` directory that contains the static website that can
20-
be accessed with a web browser.
20+
Alternatively, you may also run the web server container (Apache) as a
21+
background daemon like this:
2122

22-
## Deploy
23-
24-
Then deploy `build/` behind your favorite webserver (Apache + PHP-FPM etc.).
25-
26-
Additionally, this should be deployed behind a reverse proxy (nginx) that is
27-
responsible for HTTPS certificate handling and forcing HTTPS redirects.
28-
29-
Additionally, Apache has been configured to cache static files for 1 day.
23+
```bash
24+
make served
25+
```
3026

31-
For testing purposes, you can use the official `php` docker image like this:
27+
Once running, you can run some integration tests that check correct paths etc.
28+
like this:
3229

3330
```bash
34-
docker run -it --rm -p 80:80 -v "$PWD"/build:/var/www/html php:8.1-apache sh -c "ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
31+
make test
3532
```
3633

37-
## Tests
34+
> This test assumes you're running the above web server container on
35+
> `http://clue.localhost`. You may test other deployments like this:
36+
>
37+
> ```bash
38+
> tests/acceptance.sh https://clue.example
39+
> ```
3840
39-
You can run some simple acceptance tests to verify the deployed website works
40-
as expected by running:
41+
Once done, you can clean up like this:
4142
4243
```bash
43-
tests/acceptance.sh https://clue.test
44+
make clean
4445
```
4546
46-
If you're using the above `php` docker image, you can run this test like this:
47+
## Deploy
4748

48-
```bash
49-
tests/acceptance.sh http://clue.localhost
50-
```
49+
Once built (see previous "Build" section), you can simply deploy the `build/`
50+
directory behind your favorite web server (Apache + PHP-FPM etc.).
51+
52+
Additionally, this should be deployed behind a reverse proxy (nginx) that is
53+
responsible for HTTPS certificate handling and forcing HTTPS redirects.
54+
55+
Additionally, Apache has been configured to cache static files for 1 day.

tests/acceptance.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
#run with base url argument like "http://clue.test" or "https://user:pass@clue.test"
4-
base=${1:-http://clue.test}
3+
#run with base url argument like "http://clue.localhost" or "https://user:pass@clue.example"
4+
base=${1:-http://clue.localhost}
55
redir=$(echo $base | sed "s,://.*@,://,g")
66
echo -n "Testing $redir"
77

0 commit comments

Comments
 (0)