Skip to content

Commit

Permalink
ci: add e2e asserting that setup works for users
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Apr 29, 2022
1 parent 8a3ed72 commit 5497a77
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 34 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e2e/
9 changes: 8 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
# The type of runner that the job will run on
runs-on: ubuntu-latest

strategy:
matrix:
folder:
- "."
- "e2e/workspace"

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand All @@ -32,4 +38,5 @@ jobs:
env:
# Bazelisk will download bazel to here, ensure it is cached between runs.
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
working-directory: ${{ matrix.folder }}
run: bazel --bazelrc=$GITHUB_WORKSPACE/.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
37 changes: 4 additions & 33 deletions .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -o errexit -o nounset -o pipefail
# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# Strip leading 'v'
PREFIX="rules_swc-${TAG:1}"
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')

Expand All @@ -18,37 +19,7 @@ http_archive(
strip_prefix = "${PREFIX}",
url = "https://github.com/aspect-build/rules_swc/archive/refs/tags/${TAG}.tar.gz",
)
# Fetches the rules_swc dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
# Alternatively, you can skip calling this function, so long as you've
# already fetched all the dependencies.
load("@aspect_rules_swc//swc:dependencies.bzl", "rules_swc_dependencies")
rules_swc_dependencies()
# Fetches a pre-built Rust-node binding from
# https://github.com/swc-project/swc/releases.
# If you'd rather compile it from source, you can use rules_rust, fetch the project,
# then register the toolchain yourself. (Note, this is not yet documented)
load("@aspect_rules_swc//swc:repositories.bzl", "swc_register_toolchains")
swc_register_toolchains(
name = "swc",
swc_version = "v1.2.168",
)
# Fetches a NodeJS interpreter, needed to run the swc CLI.
# You can skip this if you already register a nodejs toolchain.
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")
nodejs_register_toolchains(
name = "node16",
node_version = "16.9.0",
)
load("@aspect_bazel_lib//lib:repositories.bzl", "DEFAULT_YQ_VERSION", "register_yq_toolchains")
register_yq_toolchains(
version = DEFAULT_YQ_VERSION,
)
\`\`\`
EOF

awk 'f;/--SNIP--/{f=1}' e2e/workspace/WORKSPACE
echo "\`\`\`"
Empty file added e2e/workspace/.bazelrc
Empty file.
9 changes: 9 additions & 0 deletions e2e/workspace/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@aspect_rules_swc//swc:swc.bzl", "swc")

swc(name = "transpile")

build_test(
name = "test",
targets = [":transpile"],
)
48 changes: 48 additions & 0 deletions e2e/workspace/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Override http_archive for local testing
local_repository(
name = "aspect_rules_swc",
path = "../..",
)

#---SNIP--- Below here is re-used in the workspace snippet published on releases

###################
# rules_swc setup #
###################

# Fetches the rules_swc dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
# Alternatively, you can skip calling this function, so long as you've
# already fetched all the dependencies.
load("@aspect_rules_swc//swc:dependencies.bzl", "rules_swc_dependencies")

rules_swc_dependencies()

# Fetches a pre-built Rust-node binding from
# https://github.com/swc-project/swc/releases.
# If you'd rather compile it from source, you can use rules_rust, fetch the project,
# then register the toolchain yourself. (Note, this is not yet documented)
load("@aspect_rules_swc//swc:repositories.bzl", "swc_register_toolchains")

swc_register_toolchains(
name = "swc",
swc_version = "v1.2.168",
)

# Fetches a NodeJS interpreter, needed to run the swc CLI.
# You can skip this if you already register a nodejs toolchain.
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "node",
node_version = DEFAULT_NODE_VERSION,
)

# yq is needed for converting pnpm-lock.yaml into json
# so that it can be parsed in starlark.
load("@aspect_bazel_lib//lib:repositories.bzl", "DEFAULT_YQ_VERSION", "register_yq_toolchains")

register_yq_toolchains(
version = DEFAULT_YQ_VERSION,
)
1 change: 1 addition & 0 deletions e2e/workspace/foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1;

0 comments on commit 5497a77

Please sign in to comment.