Skip to content

Commit

Permalink
ch_checker: Add copyright check for yml files
Browse files Browse the repository at this point in the history
All source files need to have copyright header based on Eclipse
Foundation handbook and yml files are source files for GitHub
Actions and Workflows. Addition to adding copyright header to
each yml file, the cr_checker will also now check their existance
in every new yml file that is added into repository.

Issue-ref: resolves #6
  • Loading branch information
nradakovic committed Nov 29, 2024
1 parent a2a2141 commit a1c1dc2
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 14 deletions.
13 changes: 13 additions & 0 deletions .github/actions/gitlint/action.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

name: "Gitlint Action"
description: "An action to install and run Gitlint on PR commits"
inputs:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/copyright.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

name: Copyright checks
on:
pull_request:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

name: Documentation build
on:
pull_request:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

name: Formatting checks
on:
pull_request:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/gitlint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

name: Gitlint check
on:
pull_request:
Expand Down
3 changes: 2 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ alias(
filegroup(
name = "repo_directories",
srcs = [
".github",
"docs",
"tools",
"tools/format",
],
visibility = [
"//tools/cr_checker:__subpackages__",
Expand Down
13 changes: 13 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

module(
name = "score_platform",
version = "0.1",
Expand Down
1 change: 0 additions & 1 deletion tools/cr_checker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ check(
"//:MODULE.bazel",
"//:repo_directories",
],
offset = 24,
visibility = ["//visibility:public"],
)

Expand Down
4 changes: 3 additions & 1 deletion tools/cr_checker/cr_checker.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _cr_impl(ctx):

ctx.actions.write(
output = ctx.outputs.executable,
content = "{tool}.py -t {template} {extensions} {fix} {use_mmap} {debug} {log_file} {offset} {srcs}".format(
content = "{tool} -t {template} {extensions} {fix} {use_mmap} {debug} {log_file} {offset} {srcs}".format(
tool = script.files_to_run.executable.short_path,
template = ctx.file.template.path,
extensions = text_exts,
Expand Down Expand Up @@ -72,6 +72,8 @@ _cr_rule = rule(
"use_memory_map": attr.bool(mandatory = False, default = False),
"_script": attr.label(
default = Label("//tools/cr_checker/tool:cr_checker"),
executable = True,
cfg = "exec",
),
},
)
Expand Down
3 changes: 1 addition & 2 deletions tools/cr_checker/resources/templates.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

[py,sh,bzl,ini,BUILD]
[py,sh,bzl,ini,yml,BUILD,bazel]
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
Expand Down Expand Up @@ -53,4 +53,3 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

24 changes: 15 additions & 9 deletions tools/cr_checker/tool/cr_checker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env python3

# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
Expand Down Expand Up @@ -536,16 +534,24 @@ def main(argv=None):
LOGGER.info("Process completed.")
LOGGER.info(
"Total files without copyright: %s%d%s",
COLORS["GREEN"],
COLORS["RED"] if total_no > 0 else COLORS["GREEN"],
total_no,
COLORS["ENDC"],
)
LOGGER.info(
"Total files that were fixed: %s%d%s",
COLORS["RED"] if total_fixes > 0 else COLORS["GREEN"],
total_fixes,
COLORS["ENDC"],
)
if args.fix:
total_not_fixed = total_no - total_fixes
LOGGER.info(
"Total files that were fixed: %s%d%s",
COLORS["GREEN"],
total_fixes,
COLORS["ENDC"],
)
LOGGER.info(
"Total files that were NOT fixed: %s%d%s",
COLORS["RED"] if total_not_fixed > 0 else COLORS["GREEN"],
total_not_fixed,
COLORS["ENDC"],
)
LOGGER.info("=" * 64)

return 0 if total_no == 0 else 1
Expand Down

0 comments on commit a1c1dc2

Please sign in to comment.