Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated, byte-compared files stay LF on every platform so
# `make conformance-status-check` behaves the same on Windows and Unix.
conformance/*.json text eol=lf
README.md text eol=lf
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
- name: verify conformance corpus
run: go run ./cmd/openiac-conformance verify

- name: check conformance summary
run: go run ./cmd/openiac-conformance status -check

- name: build CLI
run: go build -o bin/openiac ./cmd/openiac

Expand Down
45 changes: 0 additions & 45 deletions .github/workflows/pages.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ playground/wasm_exec.js
conformance/reports/
.cache/

# ---- Cloudflare deployment (local only) ----
# The Wrangler project and its state live outside the repository.
/deploy/
.wrangler/
.dev.vars
.dev.vars.*

# ---- Node ----
node_modules/
npm-debug.log*
Expand Down
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,51 @@ Serve the playground locally:
python3 -m http.server -d playground 8080
```

### Running the playground

The playground is static. `make wasm` writes `main.wasm` and `wasm_exec.js` into
`playground/`, and any static file server can host that folder:

```bash
make wasm
python3 -m http.server -d playground 8080 # http://localhost:8080
```

### Deploying the playground

Production is served from a Cloudflare Worker, deployed by a maintainer from a
machine with Wrangler installed. The Wrangler project is intentionally **not** in
this repository: `deploy/` is git-ignored together with Wrangler's `.wrangler/`
state and any `.dev.vars` secrets. A fresh clone therefore has no deploy folder,
and nothing about the deployment is committed.

To stand up an equivalent Worker yourself, create the project outside this
repository and point it at the built playground:

1. `npm install --save-dev wrangler` (Wrangler 4 or later).
2. Add a `wrangler.jsonc` that serves `playground/` as static assets and routes
other requests through a script:

```jsonc
{
"name": "openiac",
"main": "src/index.js",
"compatibility_date": "2026-10-26",
"assets": {
"directory": "/absolute/path/to/OpenIaC/playground",
"binding": "ASSETS"
},
"observability": { "enabled": true }
}
```

3. Add a `src/index.js` fetch handler that answers `GET /api/health` with
`Response.json({ status: "ok", service: "openiac" })` and otherwise returns
`env.ASSETS.fetch(request)`.
4. Run `make wasm` in this repository, then `wrangler deploy` in the project.

Deployment is manual. CI only builds the WebAssembly bundle and never deploys.

## The fastest contribution: a resource mapping

You do **not** need Go to add AWS resource support.
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GO ?= go
BIN := bin/openiac
PLAYGROUND := playground

.PHONY: all build test vet fmt tidy wasm playground clean hooks conformance-inputs conformance-verify conformance-lock
.PHONY: all build test vet fmt tidy wasm playground clean hooks conformance-inputs conformance-verify conformance-lock conformance-status conformance-status-check

all: build

Expand Down Expand Up @@ -38,6 +38,14 @@ conformance-verify:
conformance-lock:
$(GO) run ./cmd/openiac-conformance lock

# Parse the whole corpus and refresh the summary the README renders.
conformance-status:
$(GO) run ./cmd/openiac-conformance status

# Fail when the committed summary no longer matches the corpus.
conformance-status-check:
$(GO) run ./cmd/openiac-conformance status -check

# Build the browser playground. Copies wasm_exec.js from the local toolchain,
# which lives in a different directory depending on the Go version.
wasm:
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ One parser. One IR. Zero lock-in.
[![Terraform](https://img.shields.io/badge/Terraform-1.0_%E2%80%93_1.17-7B42BC?style=flat-square&logo=terraform&logoColor=white)](docs/TERRAFORM-VERSIONS.md)
[![AWS CDK](https://img.shields.io/badge/AWS_CDK-TypeScript-FF9900?style=flat-square&logo=amazonaws&logoColor=white)](https://aws.amazon.com/cdk/)
[![Pulumi](https://img.shields.io/badge/Pulumi-TypeScript-8A3391?style=flat-square&logo=pulumi&logoColor=white)](https://www.pulumi.com/)
[![Cloudflare Workers](https://img.shields.io/badge/Cloudflare-Workers-F38020?style=flat-square&logo=cloudflare&logoColor=white)](https://openiac.cwz.workers.dev)
[![IR](https://img.shields.io/badge/IR-schema_0.2-818cf8?style=flat-square)](docs/IR.md)
[![Made with Go](https://img.shields.io/badge/made_with-Go-00ADD8?style=flat-square&logo=go&logoColor=white)](https://go.dev)

Expand All @@ -27,7 +28,7 @@ One parser. One IR. Zero lock-in.

<br/>

[🚀 Playground](playground/) · [📦 Quick Start](#-quick-start) · [🗺️ Roadmap](docs/ROADMAP.md) · [🧠 How It Works](#-how-it-works) · [🧱 Architecture](docs/ARCHITECTURE.md) · [📄 IR Reference](docs/IR.md) · [🧭 Version Support](docs/TERRAFORM-VERSIONS.md) · [🧪 Conformance](docs/CONFORMANCE.md) · [🤝 Contribute](CONTRIBUTING.md)
[🚀 Playground](https://openiac.cwz.workers.dev) · [📦 Quick Start](#-quick-start) · [🗺️ Roadmap](docs/ROADMAP.md) · [🧠 How It Works](#-how-it-works) · [🧱 Architecture](docs/ARCHITECTURE.md) · [📄 IR Reference](docs/IR.md) · [🧭 Version Support](docs/TERRAFORM-VERSIONS.md) · [🧪 Conformance](docs/CONFORMANCE.md) · [🤝 Contribute](CONTRIBUTING.md)

</div>

Expand Down Expand Up @@ -337,10 +338,28 @@ commit, records the input-tree hash, carries the upstream license and is scanned
for executables and credentials before it enters the tree. CI re-verifies the
tree, its lock and the generated attribution on every pull request.

[![conformance](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fbe-thomas%2FOpenIaC%2Fmain%2Fconformance%2Fbadge.json&style=flat-square)](conformance/status.json)

<!-- conformance:summary:start -->
```mermaid
xychart-beta
title "Fixtures by minimum Terraform version"
x-axis ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11"]
y-axis "Fixtures" 0 --> 500
bar [477, 34, 4, 168, 1, 117, 15, 3, 6, 9, 6, 13]
Comment thread
be-thomas marked this conversation as resolved.
Resolved
```
<!-- conformance:summary:end -->

Every one of the 853 modules parses into schema `0.2` IR. The chart groups each
module by the oldest Terraform release its configuration needs; the exact
distribution is in [`conformance/status.json`](conformance/status.json), which
`make conformance-status` regenerates and CI checks.

```bash
make conformance-inputs # refresh from configured sources
make conformance-verify # check the committed tree and lock
make conformance-lock # regenerate the lock and attribution
make conformance-status # re-parse the corpus, refresh the summary
cat conformance/corpus.lock.json # aggregate counts and tree hash
```

Expand All @@ -365,7 +384,7 @@ See [docs/CONFORMANCE.md](docs/CONFORMANCE.md) for the L0–L4 oracle design and
| Milestone | Date | Highlights | State |
|:--|:--|:--|:--:|
| **Foundation** | Oct 2026 | HCL parser · IR · DAG · CDK + Pulumi emitters · WASM playground | ✅ |
| **v0.1 Public Alpha** | Nov 2026 | Docs incl. [IR](docs/IR.md) & [version](docs/TERRAFORM-VERSIONS.md) references · tests · CI · GitHub Pages playground | 🚧 |
| **v0.1 Public Alpha** | Nov 2026 | Docs incl. [IR](docs/IR.md) & [version](docs/TERRAFORM-VERSIONS.md) references · tests · CI · Cloudflare Workers playground | 🚧 |
| **v0.2 Depth** | Dec 2026 | Data sources · `locals` · richer L2 mappings | ⏳ |
| **v0.3 Scale** | Q1 2027 | Modules · `count` / `for_each` · multi-file imports | ⏳ |
| **v1.0 Stable** | Q2 2027 | CloudFormation + Terraform backends · plugin API | 🎯 |
Expand Down
112 changes: 111 additions & 1 deletion cmd/openiac-conformance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main

import (
"context"
"encoding/json"
"flag"
"fmt"
"os"
Expand All @@ -12,6 +13,7 @@ import (
"syscall"

"github.com/be-thomas/openiac/internal/conformance/collect"
"github.com/be-thomas/openiac/internal/conformance/status"
)

func main() {
Expand All @@ -35,6 +37,11 @@ func main() {
fmt.Fprintln(os.Stderr, "openiac-conformance:", err)
os.Exit(1)
}
case "status":
if err := runStatus(os.Args[2:]); err != nil {
fmt.Fprintln(os.Stderr, "openiac-conformance:", err)
os.Exit(1)
}
case "-h", "--help", "help":
usage()
default:
Expand All @@ -45,7 +52,7 @@ func main() {
}

func usage() {
fmt.Fprint(os.Stderr, `usage: openiac-conformance <collect|verify|lock> [flags]
fmt.Fprint(os.Stderr, `usage: openiac-conformance <collect|verify|lock|status> [flags]

collect downloads upstream modules and rewrites the fixture tree.

Expand Down Expand Up @@ -75,6 +82,16 @@ to the fixture tree and never uses the network.
-out string fixture tree (default conformance/fixtures)
-lock string lock file (default conformance/corpus.lock.json)
-third-party string attribution file (default THIRD_PARTY.md)

status parses every fixture and rewrites the committed summary the README
renders. It never uses the network.

-out string fixture tree (default conformance/fixtures)
-lock string lock file (default conformance/corpus.lock.json)
-status string summary file (default conformance/status.json)
-badge string shields.io endpoint file (default conformance/badge.json)
-readme string file holding the generated summary block (default README.md)
-check report a stale summary instead of rewriting it
`)
}

Expand Down Expand Up @@ -174,6 +191,99 @@ func runLock(args []string) error {
return nil
}

func runStatus(args []string) error {
fs := flag.NewFlagSet("status", flag.ExitOnError)
out := fs.String("out", "conformance/fixtures", "fixture tree")
lockPath := fs.String("lock", "conformance/corpus.lock.json", "lock file")
statusPath := fs.String("status", "conformance/status.json", "summary file")
badgePath := fs.String("badge", "conformance/badge.json", "shields.io endpoint file")
readmePath := fs.String("readme", "README.md", "file holding the generated summary block")
check := fs.Bool("check", false, "report a stale summary instead of rewriting it")
if err := fs.Parse(args); err != nil {
return err
}

report, err := status.Compute(*out, *lockPath)
if err != nil {
return err
}
statusJSON, err := marshalIndent(report)
if err != nil {
return err
}
badgeJSON, err := marshalIndent(report.Badge())
if err != nil {
return err
}
readme, err := os.ReadFile(*readmePath)
if err != nil {
return err
}

if *check {
var stale []string
for _, file := range []struct {
path string
want []byte
}{
{*statusPath, statusJSON},
{*badgePath, badgeJSON},
} {
got, err := os.ReadFile(file.path)
if err != nil || normalizeNewlines(string(got)) != normalizeNewlines(string(file.want)) {
stale = append(stale, file.path)
}
}
section, err := status.ExtractSection(string(readme))
if err != nil {
return fmt.Errorf("%s: %w", *readmePath, err)
}
if normalizeNewlines(section) != normalizeNewlines(report.Section()) {
stale = append(stale, *readmePath)
}
if len(stale) > 0 {
return fmt.Errorf("%s is stale: run `make conformance-status` and commit the result", strings.Join(stale, ", "))
}
fmt.Printf("status: %d/%d modules parse, summary current\n", report.Parse.Parsed, report.Parse.Modules)
return nil
}

// Render the README block before touching any file, so a missing marker
// fails the run instead of leaving half the summary rewritten.
updated, err := status.ReplaceSection(string(readme), report.Section())
if err != nil {
return fmt.Errorf("%s: %w", *readmePath, err)
}
if err := os.WriteFile(*statusPath, statusJSON, 0o644); err != nil {
return err
}
if err := os.WriteFile(*badgePath, badgeJSON, 0o644); err != nil {
return err
}
if err := os.WriteFile(*readmePath, []byte(updated), 0o644); err != nil {
return err
}
fmt.Printf("status: %d/%d modules parse\n", report.Parse.Parsed, report.Parse.Modules)
fmt.Println(report.Markdown())
return nil
}

// normalizeNewlines keeps -check independent of the checkout's line endings:
// Git for Windows hands out CRLF files for content stored as LF.
func normalizeNewlines(s string) string {
return strings.ReplaceAll(s, "\r\n", "\n")
}

// marshalIndent encodes a report the way the rest of the repository encodes
// committed JSON: two-space indent and a trailing newline.
func marshalIndent(v any) ([]byte, error) {
data, err := json.MarshalIndent(v, "", " ")
if err != nil {
return nil, err
}
return append(data, '\n'), nil
}

func githubToken() string {
for _, key := range []string{"GITHUB_TOKEN", "GH_TOKEN"} {
if v := strings.TrimSpace(os.Getenv(key)); v != "" {
Expand Down
6 changes: 4 additions & 2 deletions conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@ re-derived from the parsed features.
`collection/sources.json`.
2. Run the collector.
3. Review `git status` and the new `fixture.json` files.
4. Run `make conformance-verify` and `go test ./...`, then commit the fixtures
with the code that consumes them.
4. Run `make conformance-status`, which rewrites `status.json`, `badge.json` and
the summary block in the README.
5. Run `make conformance-verify` and `go test ./...`, then commit the fixtures,
the refreshed summary and the code that consumes them.

Do not edit vendored Terraform files. If an upstream module needs a fix, add a
note and wait for a new upstream revision. Hand-curated fixtures under a future
Expand Down
6 changes: 6 additions & 0 deletions conformance/badge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"schemaVersion": 1,
"label": "conformance",
"message": "853 / 853 modules",
"color": "brightgreen"
}
Loading
Loading