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
199 changes: 199 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
name: CI

on:
push:
branches: [main, master]
tags:
- 'v*.*.*'
pull_request:
branches: [main, master]

jobs:
format:
name: Check Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Check gofmt
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "The following files are not formatted correctly:"
echo "$unformatted"
echo ""
echo "Run 'gofmt -w .' to fix formatting"
exit 1
fi
echo "All files are properly formatted"

lint:
name: Lint
runs-on: ubuntu-latest
needs: format
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

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

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Download dependencies
run: go mod download

- name: Run unit tests
run: go test -v -count=1 ./go/...

- name: Run integration tests
run: go test -tags=integration -v -count=1

build:
name: Build
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for git describe

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Download dependencies
run: go mod download

- name: Get version from git
id: version
run: |
VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "v0.0.0-dev")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"

- name: Build binary with version
run: |
go build -ldflags "-X main.Version=${{ steps.version.outputs.version }}" -o thunderstorm-mock .

- name: Verify version in binary
run: |
./thunderstorm-mock --version
BINARY_VERSION=$(./thunderstorm-mock --version)
echo "Binary reports version: $BINARY_VERSION"
if [ "$BINARY_VERSION" != "${{ steps.version.outputs.version }}" ]; then
echo "ERROR: Binary version mismatch!"
exit 1
fi

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: thunderstorm-mock
path: thunderstorm-mock
retention-days: 7

release:
name: Release
runs-on: ubuntu-latest
needs: build
# Quick minimal test, proper one follows
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Verify tag version
id: tag
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo ""
echo "ERROR: Tag pattern mismatch!"
echo "Tag $TAG does not match the required format v[0-9]+.[0-9]+.[0-9]+"
echo ""
exit 1
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Release tag: $TAG"

- name: Validate version constant matches tag
run: |
TAG="${{ steps.tag.outputs.tag }}"
# Extract the Version constant from main.go
CODE_VERSION=$(grep -E '^var Version = ".*"$' main.go | sed 's/.*"\(.*\)".*/\1/')
echo "Tag version: $TAG"
echo "Code version constant: $CODE_VERSION"
if [ "$CODE_VERSION" != "$TAG" ]; then
echo ""
echo "ERROR: Version mismatch!"
echo "The Version constant in main.go ($CODE_VERSION) does not match the git tag ($TAG)."
echo ""
echo "Please update the Version constant in main.go to match the release tag:"
echo " var Version = \"$TAG\""
echo ""
exit 1
fi
echo "Version constant matches tag - OK"

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: thunderstorm-mock

- name: Make binary executable
run: chmod +x thunderstorm-mock

- name: Verify binary version matches tag
run: |
BINARY_VERSION=$(./thunderstorm-mock --version)
TAG="${{ steps.tag.outputs.tag }}"
echo "Binary version: $BINARY_VERSION"
echo "Tag version: $TAG"
if [ "$BINARY_VERSION" != "$TAG" ]; then
echo "ERROR: Binary version does not match tag!"
exit 1
fi
echo "Binary version matches tag - OK"

- name: Rename binary with version
run: |
TAG="${{ steps.tag.outputs.tag }}"
mv thunderstorm-mock "thunderstorm-mock-${TAG}"
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: thunderstorm-mock-${{ steps.tag.outputs.tag }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.openapi-generator/
39 changes: 39 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

# Files expected to be customized after first generation and then fixed:
# (i.e., you probably want to keep these ignores permanently, or only disable
# temporarily on massive API changes or huge version bumps of the generator.)
/README.md
go/*_service.go

# Files that normally shouldn't be changed, but we need changes there:
# (i.e., you might want to disable these ignores temporarily to check for
# updates in the generation code when regenerating.)
go/model_thor_finding.go
go/model_thor_report.go
go/model_timestamp_map.go
go/logger.go
main.go
go.mod
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM golang:1.19 AS build
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker build stage uses golang:1.19, but go.mod declares go 1.24.0 (and CI uses Go 1.24). This will fail to build in Docker due to an unsupported Go toolchain. Update the Docker base image to a Go version compatible with go.mod (or lower the go directive if 1.24 is not required).

Suggested change
FROM golang:1.19 AS build
FROM golang:1.24 AS build

Copilot uses AI. Check for mistakes.
WORKDIR /go/src
COPY go ./go
COPY main.go .
COPY go.sum .
COPY go.mod .

ENV CGO_ENABLED=0

RUN go build -o thunderstormmock .

FROM scratch AS runtime
COPY --from=build /go/src/thunderstormmock ./
EXPOSE 8080/tcp
ENTRYPOINT ["./thunderstormmock"]
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,80 @@
# Thunderstorm Mock Server

The server implements a mock version of the Thunderstorm API that can be used for testing purposes. All requests do nothing but log to the console.
The server implements a mock version of the Thunderstorm API that can be used for testing purposes. All requests do nothing but logging.

## Download

Download the latest release from the [Releases page](https://github.com/NextronSystems/thunderstorm-mock/releases).

## Usage

```bash
./thunderstorm-mock [options]
```

### Options

| Flag | Environment Variable | Default | Description |
|------|---------------------|---------|-------------|
| `-p, --port` | `THUNDERSTORM_MOCK_PORT` | `8080` | Port to listen on |
| `-a, --address` | `THUNDERSTORM_MOCK_ADDRESS` | (all interfaces) | Address to bind to |
| `-o, --output` | `THUNDERSTORM_MOCK_OUTPUT` | (stdout) | Log output file path |
| `-v, --version` | | | Print version and exit |
| `-h, --help` | | | Print help and exit |

CLI flags take precedence over environment variables.

### Examples

```bash
# Start server on default port 8080
./thunderstorm-mock

# Start server on port 9000
./thunderstorm-mock --port 9000

# Bind to localhost only and log to file
./thunderstorm-mock --address 127.0.0.1 --output server.log

# Using environment variables
THUNDERSTORM_MOCK_PORT=9000 ./thunderstorm-mock
```

The server will be available at `http://localhost:8080` (or your configured port).

---

## Development

### Running from Source

```bash
go run main.go
```

### Running with Docker

Build the image:
```bash
docker build --network=host -t thunderstormmock .
```

Run the container:
```bash
docker run --rm -it thunderstormmock
```

### Code Generation

This server was generated by the [openapi-generator](https://openapi-generator.tech) project using the
[Thunderstorm OpenAPI specification](https://github.com/NextronSystems/thunderstorm-openapi) and the
configuration found in `./openapi-genconfig.yaml`.

- API version: 1.0.0
- Build date: 2026-01-26T17:16:00.310597514+01:00[Europe/Berlin]
- Generator version: 7.19.0

Command used to generate this server:
```bash
GO_POST_PROCESS_FILE="gofmt -w" openapi-generator-cli generate --generator-name go-server --config ./openapi-genconfig.yaml
```
Loading