Skip to content

Commit 3344bf5

Browse files
committed
Add tests (bat-core) and CI
1 parent cc55c6a commit 3344bf5

20 files changed

Lines changed: 1032 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
name: Shellcheck
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Run shellcheck
16+
run: shellcheck hdi
17+
18+
test:
19+
name: Test (${{ matrix.os }})
20+
needs: lint
21+
strategy:
22+
matrix:
23+
os: [ubuntu-latest, macos-latest]
24+
runs-on: ${{ matrix.os }}
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Install bats-core
29+
run: |
30+
if [[ "$RUNNER_OS" == "macOS" ]]; then
31+
brew install bats-core
32+
else
33+
sudo apt-get update -qq && sudo apt-get install -qq -y bats
34+
fi
35+
36+
- name: Run tests
37+
run: bats test/hdi.bats

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ['v*']
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
release:
12+
name: Create release
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Run tests before release
18+
run: |
19+
sudo apt-get update -qq && sudo apt-get install -qq -y bats
20+
bats test/hdi.bats
21+
22+
- name: Get version from tag
23+
id: version
24+
run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
25+
26+
- name: Create GitHub release
27+
uses: softprops/action-gh-release@v2
28+
with:
29+
files: hdi
30+
generate_release_notes: true
31+
body: |
32+
## Install
33+
34+
```bash
35+
# Homebrew
36+
brew install gregannandale/tap/hdi
37+
38+
# Manual
39+
curl -fsSL https://raw.githubusercontent.com/gregannandale/hdi/${{ steps.version.outputs.version }}/hdi -o ~/.local/bin/hdi
40+
chmod +x ~/.local/bin/hdi
41+
```

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ hdi /path/to/project Scan a different directory
7979

8080
No dependencies, just Bash. Should work on macOS and Linux.
8181

82+
## Testing
83+
84+
Tests use [bats-core](https://github.com/bats-core/bats-core).
85+
86+
```bash
87+
brew install bats-core # or: apt-get install bats
88+
bats test/hdi.bats
89+
```
90+
8291
## Publishing a new release
8392

8493
1. Tag the release and push:

hdi

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ render_static() {
240240
;;
241241
empty)
242242
if $RAW; then
243-
[[ -n "$line" ]] && printf " %s\n" "$line"
243+
if [[ -n "$line" ]]; then printf " %s\n" "$line"; fi
244244
else
245-
[[ -n "$line" ]] && printf " %s%s%s\n" "$DIM" "$line" "$RESET"
245+
if [[ -n "$line" ]]; then printf " %s%s%s\n" "$DIM" "$line" "$RESET"; fi
246246
fi
247247
;;
248248
esac
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# phoenix-app
2+
3+
An Elixir/Phoenix web application.
4+
5+
## Setup
6+
7+
```bash
8+
mix deps.get
9+
mix ecto.setup
10+
```
11+
12+
## Start the server
13+
14+
```bash
15+
mix phx.server
16+
```
17+
18+
Or inside IEx:
19+
20+
```bash
21+
iex -S mix phx.server
22+
```
23+
24+
## Configuration
25+
26+
```elixir
27+
config :phoenix_app, PhoenixApp.Repo,
28+
database: "phoenix_app_dev",
29+
hostname: "localhost"
30+
```
31+
32+
## Test
33+
34+
```bash
35+
mix test
36+
```

test/fixtures/go-project/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# go-service
2+
3+
A microservice written in Go.
4+
5+
## Requirements
6+
7+
```bash
8+
brew install go
9+
```
10+
11+
## Setup
12+
13+
```bash
14+
go mod download
15+
cp config.example.yaml config.yaml
16+
```
17+
18+
## Build
19+
20+
```bash
21+
go build -o bin/service ./cmd/service
22+
```
23+
24+
## Running
25+
26+
```bash
27+
./bin/service --port 8080
28+
```
29+
30+
## Environment Variables
31+
32+
```env
33+
PORT=8080
34+
DB_HOST=localhost
35+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# spring-boot-api
2+
3+
A Spring Boot REST API.
4+
5+
## Prerequisites
6+
7+
```bash
8+
sdk install java 21-tem
9+
sdk install maven
10+
```
11+
12+
## Build
13+
14+
```bash
15+
mvn clean install
16+
```
17+
18+
## Run
19+
20+
```bash
21+
java -jar target/spring-boot-api-0.1.0.jar
22+
```
23+
24+
Or with Maven:
25+
26+
```bash
27+
mvn spring-boot:run
28+
```
29+
30+
## API Docs
31+
32+
```json
33+
{
34+
"openapi": "3.0.0",
35+
"info": { "title": "API", "version": "1.0" }
36+
}
37+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# k8s-platform
2+
3+
Kubernetes deployment with Helm charts.
4+
5+
## Dependencies
6+
7+
```bash
8+
brew install kubectl helm
9+
```
10+
11+
## Installation
12+
13+
```bash
14+
helm repo add bitnami https://charts.bitnami.com/bitnami
15+
helm install my-release bitnami/nginx
16+
```
17+
18+
## Usage
19+
20+
```bash
21+
kubectl get pods
22+
kubectl port-forward svc/my-release-nginx 8080:80
23+
```
24+
25+
## Values
26+
27+
```yaml
28+
replicaCount: 3
29+
image:
30+
repository: nginx
31+
tag: "1.25"
32+
```
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# mixed-app
2+
3+
An app with many code block types.
4+
5+
## Installation
6+
7+
Install the CLI:
8+
9+
```bash
10+
npm install -g mixed-app
11+
```
12+
13+
The config file looks like this:
14+
15+
```json
16+
{
17+
"port": 3000
18+
}
19+
```
20+
21+
Environment setup:
22+
23+
```yaml
24+
DATABASE_URL: postgres://localhost/app
25+
```
26+
27+
```toml
28+
[server]
29+
port = 3000
30+
```
31+
32+
Then initialize:
33+
34+
```shell
35+
mixed-app init
36+
```
37+
38+
## Running
39+
40+
```bash
41+
mixed-app serve
42+
```
43+
44+
Log output:
45+
46+
```log
47+
[INFO] Server started on :3000
48+
```
49+
50+
```xml
51+
<config><port>3000</port></config>
52+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# nested-project
2+
3+
## Getting Started
4+
5+
### Prerequisites
6+
7+
```bash
8+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
9+
```
10+
11+
### Quick Start
12+
13+
```bash
14+
cargo run
15+
```
16+
17+
## Development
18+
19+
### Dev Server
20+
21+
```bash
22+
cargo watch -x run
23+
```
24+
25+
### Building
26+
27+
```bash
28+
cargo build --release
29+
```
30+
31+
### Testing
32+
33+
```bash
34+
cargo test
35+
```

0 commit comments

Comments
 (0)