Skip to content

Commit

Permalink
chore: Integrate rules_lint and format files
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmeku authored and gregmagolan committed May 17, 2024
1 parent 96ee05d commit d4fcaf8
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="rules_cypress-${TAG:1}"
ARCHIVE="rules_cypress-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip >$ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
cat <<EOF
WORKSPACE snippet:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Expand Down
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
load("@npm//:defs.bzl", "npm_link_all_packages")

buildifier(
name = "buildifier",
Expand All @@ -17,6 +18,11 @@ buildifier(
tags = ["manual"], # tag as manual so windows ci does not build it by default
)

alias(
name = "format",
actual = "//tools/format",
)

bzl_library(
name = "internal_deps",
srcs = ["internal_deps.bzl"],
Expand All @@ -26,3 +32,5 @@ bzl_library(
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)

npm_link_all_packages(name = "node_modules")
10 changes: 10 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,13 @@ visibility = ["//visibility:public"],
"https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F" + CHROME_REVISION_LINUX + "%2Fchrome-linux.zip?alt=media",
],
)

bazel_dep(name = "aspect_rules_lint", version = "0.19.0", dev_dependency = True)

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
)
use_repo(npm, "npm")
10 changes: 5 additions & 5 deletions e2e/workspace/cli_test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2022",
"types": ["cypress", "node"]
}
}
"compilerOptions": {
"target": "ES2022",
"types": ["cypress", "node"]
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"devDependencies": {
"prettier": "^3.2.5"
}
}
"devDependencies": {
"prettier": "^3.2.5"
}
}
6 changes: 3 additions & 3 deletions scripts/mirror_releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Produce a dictionary for the current cypress release,
# suitable for appending to cypress/private/versions.bzl
set -o errexit -o nounset
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

version="${1:-$(curl --silent "https://registry.npmjs.org/cypress/latest" | jq --raw-output ".version")}"

echo " \"$version\": {"
for pkg in darwin-{x,arm}64 linux-{x,arm}64 win32-x64; do
sha256=($(curl -sL "https://cdn.cypress.io/desktop/${version}/${pkg}/cypress.zip" | shasum -a 256))
echo " \"$pkg\": \"$sha256\","
sha256=($(curl -sL "https://cdn.cypress.io/desktop/${version}/${pkg}/cypress.zip" | shasum -a 256))
echo " \"$pkg\": \"$sha256\","
done
echo " },"
echo
Expand Down
16 changes: 16 additions & 0 deletions tools/format/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
load("@npm//:prettier/package_json.bzl", prettier = "bin")

package(default_visibility = ["//visibility:public"])

prettier.prettier_binary(
name = "prettier",
# Allow the binary to be run outside bazel
env = {"BAZEL_BINDIR": "."},
)

format_multirun(
name = "format",
javascript = ":prettier",
yaml = None, # yaml formatter removes whitespace in CI config yamls
)

0 comments on commit d4fcaf8

Please sign in to comment.