Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI

on:
push:
pull_request:

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y socat ncat bats curl openssl

- name: Build single-file artifact
# Exercise the Makefile + inliner so the single-file build can't bitrot.
# (The single_file.bats test under tests/integration also rebuilds it.)
run: make build

- name: Smoke-test the single-file artifact
run: dist/bashttpd version

- name: Run test suite
run: |
if [[ -x ./tests/run ]]; then
./tests/run
else
bats --recursive tests/
fi

lint:
name: Lint (shellcheck)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck

- name: Run shellcheck
run: shellcheck bashttpd bin/bashttpd lib/bashttpd/*.sh scripts/*.sh

- name: Build and shellcheck the single-file artifact
# The generated dist/bashttpd must stay lint-clean too.
run: |
make build
shellcheck dist/bashttpd
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

# On any pushed v* tag: build the self-contained single file and publish it as
# a release asset named `bashttpd`, so that
# curl -LO https://github.com/avleen/bashttpd/releases/latest/download/bashttpd
# fetches a ready-to-run server.

on:
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
name: Build and publish single-file release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # so `git describe --tags` can stamp the build

- name: Build single-file artifact
run: make build

- name: Smoke-test the artifact
run: |
test -x dist/bashttpd
dist/bashttpd version

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
files: dist/bashttpd
fail_on_unmatched_files: true
generate_release_notes: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Build artifacts. The single-file build is produced on demand / in CI and
# attached to releases; it is never committed.
/dist/
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# bashttpd -- developer Makefile (GNU make).
#
# make build build the self-contained single file into dist/bashttpd
# make test run the bats test suite (./tests/run)
# make lint run shellcheck over every shell source
# make check lint + test
# make clean remove dist/

SHELL := /bin/bash

LIB_SOURCES := $(wildcard lib/bashttpd/*.sh)
DIST := dist/bashttpd

SHELL_SOURCES := bashttpd bin/bashttpd $(LIB_SOURCES) $(wildcard scripts/*.sh)

.PHONY: build test lint check clean

build: $(DIST)

$(DIST): bin/bashttpd $(LIB_SOURCES) scripts/build-single.sh
./scripts/build-single.sh

test:
./tests/run

lint:
shellcheck $(SHELL_SOURCES)

check: lint test

clean:
rm -rf dist
Loading
Loading