Skip to content

Commit

Permalink
Merge branch 'master' into feature/loeffel-io/docker
Browse files Browse the repository at this point in the history
  • Loading branch information
loeffel-io committed Nov 19, 2024
2 parents 5ddc6e0 + 61ffb56 commit 3bf7a48
Show file tree
Hide file tree
Showing 53 changed files with 2,461 additions and 399 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
8.0.0rc2
34 changes: 25 additions & 9 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
name: Bazel
on: [ push ]
on: [ push, pull_request ]

jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
container:
image: gcr.io/bazel-public/bazel@sha256:3348b14c7b45a4fbf06fee34996a8d15da72f43bb282a81f4720a0c0a5c37dca # v6.3.2
options: --user root # ref: https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user
image: gcr.io/bazel-public/bazel@sha256:35c128509642f76fede4ade16e8c829781048f6a62a7b2d9cfbabd45246af81a
options: --user root
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GOOGLE_BUCKET: https://storage.googleapis.com/ls-lint-bazel
steps:
- run: set -eu
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v1
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- run: bazel run --remote_cache=$GOOGLE_BUCKET --google_default_credentials //:gazelle_fix_diff
- run: bazel test --remote_cache=$GOOGLE_BUCKET --google_default_credentials //...
- run: bazel build --remote_cache=$GOOGLE_BUCKET --google_default_credentials //...
- run: bazel run //cmd/ls_lint:ls-lint -- --config ${PWD}/.ls-lint.yml --workdir ${PWD}

build-no-cache: # external pull requests
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
container:
image: gcr.io/bazel-public/bazel@sha256:35c128509642f76fede4ade16e8c829781048f6a62a7b2d9cfbabd45246af81a
options: --user root
steps:
- run: set -eu
- uses: actions/checkout@v4
- run: bazel run //:gazelle_fix_diff
- run: bazel test //...
- run: bazel build //...
- run: bazel run //cmd/ls_lint:ls-lint -- --config ${PWD}/.ls-lint.yml --workdir ${PWD}

release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
container:
image: gcr.io/bazel-public/bazel@sha256:3348b14c7b45a4fbf06fee34996a8d15da72f43bb282a81f4720a0c0a5c37dca # v6.3.2
image: gcr.io/bazel-public/bazel@sha256:35c128509642f76fede4ade16e8c829781048f6a62a7b2d9cfbabd45246af81a
options: --user root # ref: https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions#user
env:
GH_TOKEN: ${{ github.token }}
STABLE_GIT_TAG: ${{ github.ref_name }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GOOGLE_BUCKET: https://storage.googleapis.com/ls-lint-bazel
steps:
- run: set -eu && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
- run: set -eu
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v1
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
- run: bazel run --remote_cache=$GOOGLE_BUCKET --google_default_credentials //deployments/github:ls_lint_publish
- run: bazel build --remote_cache=$GOOGLE_BUCKET --google_default_credentials //deployments/npm:ls_lint
- run: (cd bazel-bin/deployments/npm/ls_lint && NPM_CONFIG_USERCONFIG=${GITHUB_WORKSPACE}/deployments/npm/.npmrc npm publish --no-git-checks) # workaround: https://bazelbuild.slack.com/archives/CEZUUKQ6P/p1667995025343689 # --dry-run --tag beta
- run: NPM_CONFIG_USERCONFIG=${GITHUB_WORKSPACE}/deployments/npm/.npmrc bazel run --remote_cache=$GOOGLE_BUCKET --google_default_credentials //deployments/npm:ls_lint.publish
2 changes: 1 addition & 1 deletion .github/workflows/github-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ls-lint/action@v2.2.2
- uses: ls-lint/action@v2.3.0-beta.3
27 changes: 20 additions & 7 deletions .ls-lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
ls:
.dir: snake_case
.bzl: snake_case
.sh: snake_case
.*: snake_case
.*.*: snake_case
.*.*.*: exists:0
.png: exists:0
.jpg: exists:0
.md: SCREAMING_SNAKE_CASE
.bazel: SCREAMING_SNAKE_CASE
.go: snake_case
.yaml: snake_case
.js: snake_case
.bazel.lock: SCREAMING_SNAKE_CASE

examples/**: # allow only .yml files
.dir: snake_case
.*: exists:0
.yml: kebab-case

assets/**: # allow only .png files
.dir: snake_case
.*: exists:0
.png: kebab-case

ignore:
- .git
- .github
- .idea
- genhtml
- bazel-*
- deployments/npm/pnpm-lock.yaml
- gha-*
- deployments/npm/pnpm-lock.yaml
- deployments/docker
14 changes: 11 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")
load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "nogo")

# gazelle:prefix github.com/loeffel-io/ls-lint/v2
# gazelle:exclude vendor
# gazelle:exclude .idea
gazelle(name = "gazelle")

gazelle(
name = "gazelle_fix_diff",
command = "fix",
extra_args = ["--mode=diff"],
)

config_setting(
name = "darwin_arm64",
constraint_values = [
Expand All @@ -17,7 +25,7 @@ nogo(
name = "nogo",
config = ":nogo.json",
visibility = ["//visibility:public"],
deps = TOOLS_NOGO + [],
deps = [], # TOOLS_NOGO: https://github.com/bazel-contrib/rules_go/issues/3924
)

exports_files(
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2023 Lucas Löffel
Copyright (c) 2020-2025 Lucas Löffel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
103 changes: 103 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True)
bazel_dep(name = "rules_go", version = "0.50.1", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.40.0", dev_dependency = True)
bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.9.4", dev_dependency = True)
bazel_dep(name = "aspect_rules_js", version = "2.1.0", dev_dependency = True)

####################################################################
# rules_go #########################################################
####################################################################

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.23.3")
go_sdk.nogo(nogo = "//:nogo")

####################################################################
# gazelle ##########################################################
# upgrade with bazel run @rules_go//go mod tidy && bazel mod tidy ##
####################################################################

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_bmatcuk_doublestar_v4",
"in_gopkg_yaml_v3",
"org_golang_x_sync",
)

####################################################################
# rules_js #########################################################
####################################################################

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
npmrc = "//deployments/npm:.npmrc",
pnpm_lock = "//deployments/npm:pnpm-lock.yaml",
)
use_repo(npm, "npm")

####################################################################
# rules_python #####################################################
# https://github.com/bazelbuild/rules_python/pull/713 ##############
####################################################################

bazel_dep(name = "rules_python", version = "0.40.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
ignore_root_user_error = True,
python_version = "3.13",
)

####################################################################
# github cli #######################################################
####################################################################

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_github_cli_cli_darwin_arm64",
build_file_content = """exports_files(glob(["bin/*"]))""",
sha256 = "fdb77f31b8a6dd23c3fd858758d692a45f7fc76383e37d475bdcae038df92afc",
strip_prefix = "gh_2.62.0_macOS_arm64",
urls = [
"https://github.com/cli/cli/releases/download/v2.62.0/gh_2.62.0_macOS_arm64.zip",
],
)

http_archive(
name = "com_github_cli_cli_linux_amd64",
build_file_content = """exports_files(glob(["bin/*"]))""",
sha256 = "41c8b0698ad3003cb5c44bde672a1ffd5f818595abd80162fbf8cc999418446a",
strip_prefix = "gh_2.62.0_linux_amd64",
urls = [
"https://github.com/cli/cli/releases/download/v2.62.0/gh_2.62.0_linux_amd64.tar.gz",
],
)

####################################################################
# coreutils (sha256) ###############################################
####################################################################

http_archive(
name = "com_github_uutils_coreutils_darwin_arm64",
build_file_content = """exports_files(["coreutils"])""",
sha256 = "bbd9b97fc38b9e8841feb93b5684f3587afb3d651a1cc91e46d00b1b0bcf28f6",
strip_prefix = "coreutils-0.0.28-aarch64-apple-darwin",
urls = [
"https://github.com/uutils/coreutils/releases/download/0.0.28/coreutils-0.0.28-aarch64-apple-darwin.tar.gz",
],
)

http_archive(
name = "com_github_uutils_coreutils_linux_amd64",
build_file_content = """exports_files(["coreutils"])""",
sha256 = "e22a4a9179bbde667865917dc1399e4686a18159da35be6c1b78582c52a373a2",
strip_prefix = "coreutils-0.0.28-x86_64-unknown-linux-gnu",
urls = [
"https://github.com/uutils/coreutils/releases/download/0.0.28/coreutils-0.0.28-x86_64-unknown-linux-gnu.tar.gz",
],
)
Loading

0 comments on commit 3bf7a48

Please sign in to comment.