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
2 changes: 2 additions & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
9.2.0

29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "main"

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}.${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
copyright-headers-check:
runs-on: ubuntu-latest
timeout-minutes: 10

env:
ARCH: "x64"
OS: "linux"

steps:
- uses: actions/checkout@v4

- name: Check copyright headers
if: success()
run: |
bazel run //infra/internal/check_copyright_headers
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
__pycache__/
*.py[cod]

# Bazel stuff
/bazel-*

# Local symlink to a target repo used for a migration dry-run (Dolphin)
dolphin_migration

Expand Down
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# Name or Organization <email address>
# The email address is not required for organizations.

EngFlow GmbH
EngFlow Inc.
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module(name = "any2bazel", version = "0.1.0")

bazel_dep(name = "rules_go", version = "0.63.0")
639 changes: 639 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/ladybird/workspace/Meta/bazel_parity_harness.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
14 changes: 14 additions & 0 deletions examples/ladybird/workspace/Meta/cargo_binary_build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build a cargo BINARY crate offline: flapc, the Flap-DSL -> interpreter-assembly
# compiler. Driver for the cargo_binary build action (see cargo.bzl).
#
Expand Down
14 changes: 14 additions & 0 deletions examples/ladybird/workspace/Meta/cargo_build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build ONE of Ladybird's Rust staticlib crates with cargo, offline, from crates
# Bazel already fetched. Driver for the cargo_crate build action (see cargo.bzl).
#
Expand Down
14 changes: 14 additions & 0 deletions examples/ladybird/workspace/Meta/cargo_vendor.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Shared staging for the two cargo drivers (cargo_build.sh, cargo_binary_build.sh).
# Sourced, not executed: it sets up the environment those two then run cargo in.
#
Expand Down
2 changes: 1 addition & 1 deletion examples/ladybird/workspace/Meta/emit_build_bazel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/ladybird/workspace/Meta/emit_cargo_bazel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/ladybird/workspace/Meta/emit_codegen_bazel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/ladybird/workspace/Meta/emit_libweb_bazel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion examples/ladybird/workspace/Meta/emit_vcpkg_bazel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
14 changes: 14 additions & 0 deletions examples/ladybird/workspace/Meta/vcpkg_build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build Ladybird's vcpkg dependency tree with ZERO network access, from
# distfiles Bazel already fetched. Driver for the vcpkg_tree build action.
#
Expand Down
14 changes: 14 additions & 0 deletions examples/ladybird/workspace/Meta/vcpkg_capture_assets.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/bash
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Record every (url, sha512, filename) vcpkg asks for, by BEING its asset cache.
#
# Why this exists: the first version of Meta/emit_vcpkg_bazel.py re-parsed
Expand Down
15 changes: 15 additions & 0 deletions infra/internal/check_copyright_headers/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@rules_go//go:go_binary.bzl", "go_binary")
load("@rules_go//go:go_library.bzl", "go_library")

go_library(
name = "check_copyright_headers_lib",
srcs = ["main.go"],
importpath = "github.com/EngFlow/auth/infra/internal/check_copyright_headers",
visibility = ["//infra:__subpackages__"],
)

go_binary(
name = "check_copyright_headers",
embed = [":check_copyright_headers_lib"],
visibility = ["//infra:__subpackages__"],
)
146 changes: 146 additions & 0 deletions infra/internal/check_copyright_headers/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Copyright 2026 EngFlow Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"errors"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"
)

var (
skipRegexps = []*regexp.Regexp{
regexp.MustCompile(`(^|/)LICENSE$`),
regexp.MustCompile(`(^|/)AUTHORS$`),
regexp.MustCompile(`^MODULE\.bazel\.lock$`),
regexp.MustCompile(`MODULE\.bazel$`),
regexp.MustCompile(`(/|^)BUILD$`),
regexp.MustCompile(`\.bazelrc$`),
regexp.MustCompile(`bazelrc.txt$`),
regexp.MustCompile(`^\.bazelversion$`),
regexp.MustCompile(`^\.gitignore$`),
regexp.MustCompile(`BUILD(?:\.bazel)$`),
regexp.MustCompile(`\.bzl$`),
regexp.MustCompile(`\.md$`),
regexp.MustCompile(`\.tsv$`),
regexp.MustCompile(`\.patch$`),
regexp.MustCompile(`\.json$`),
regexp.MustCompile(`\.yaml$`),
regexp.MustCompile(`\.yml$`),
}
copyrightHeaderRe = regexp.MustCompile(
`(#|//|::) Copyright [0-9-]+ EngFlow Inc\.
(#|//|::)
(#|//|::) Licensed under the Apache License, Version 2\.0 \(the "License"\);
(#|//|::) you may not use this file except in compliance with the License\.
(#|//|::) You may obtain a copy of the License at
(#|//|::)
(#|//|::) http://www\.apache\.org/licenses/LICENSE-2\.0
(#|//|::)
(#|//|::) Unless required by applicable law or agreed to in writing, software
(#|//|::) distributed under the License is distributed on an "AS IS" BASIS,
(#|//|::) WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.
(#|//|::) See the License for the specific language governing permissions and
(#|//|::) limitations under the License\.
`)
)
Comment thread
armandomontanez marked this conversation as resolved.

// listSourceFiles returns the list of files that git cares about in the current
// commit.
func listSourceFiles(repoRoot string) ([]string, error) {
cmd := exec.Command("git", "ls-tree", "-r", "--name-only", "HEAD")
cmd.Dir = repoRoot
output, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("`git ls-tree` failed: %w", err)
}
return strings.Split(strings.TrimSpace(string(output)), "\n"), nil
}

// filterStrings returns strings in `universe` that don't match any regexps in
// `remove`.
func filterStrings(universe []string, remove []*regexp.Regexp) []string {
var filtered []string
nextStr:
for _, s := range universe {
for _, r := range remove {
if r.MatchString(s) {
continue nextStr
}
}
filtered = append(filtered, s)
}
return filtered
}

// checkCopyright scans for a valid copyright header within a file, returning
// an error if no valid copyright header is found.
func checkCopyright(path string) error {
f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()
r := io.LimitReader(f, 1000)
s, e := io.ReadAll(r)
if e != nil {
return e
}
if !copyrightHeaderRe.MatchString(string(s)) {
return fmt.Errorf("%s: missing copyright header", path)
}
return nil
}

func run() error {
workspaceRoot := os.Getenv("BUILD_WORKSPACE_DIRECTORY")
if workspaceRoot == "" {
return fmt.Errorf("$BUILD_WORKSPACE_DIRECTORY is not set; please run this script via `bazel run`")
}
srcFiles, err := listSourceFiles(workspaceRoot)
if err != nil {
return err
}

srcFiles = filterStrings(srcFiles, skipRegexps)

var errs []error
for _, f := range srcFiles {
if err := checkCopyright(filepath.Join(workspaceRoot, f)); err != nil {
errs = append(errs, err)
continue
}
}

if len(errs) == 0 {
return nil
}

sort.Slice(errs, func(i, j int) bool { return errs[i].Error() < errs[j].Error() })
return fmt.Errorf("copyright header check failed:\n%v", errors.Join(errs...))
}

func main() {
if err := run(); err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
os.Exit(1)
}
}
2 changes: 1 addition & 1 deletion scripts/canonicalize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion scripts/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion scripts/diff.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion scripts/diff_ts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_bazel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_cmake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2026 EngFlow GmbH
# Copyright 2026 EngFlow Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading
Loading