Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.
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
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
startup --output_base ./build
build --color=yes --workspace_status_command=./buildvars.sh
126 changes: 36 additions & 90 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("//bazel-rules:gen_test.bzl", "gen_test")
load("//:version.bzl", "TECTONIC_VERSION")

package(
default_visibility = ["//visibility:public"],
Expand All @@ -17,7 +18,7 @@ config_setting(
)

genrule(
name = "terraform_runtime",
name = "terraform_runtime_fmt",
output_to_bindir = 1,
srcs = select({
"//:linux": ["@terraform_runtime_linux//:terraform"],
Expand All @@ -28,19 +29,6 @@ genrule(
executable = True,
)

genrule(
name = "provider_matchbox",
output_to_bindir = 1,
srcs = select({
"//:linux": ["@terraform_provider_matchbox_linux//:terraform-provider-matchbox"],
"//:darwin": ["@terraform_provider_matchbox_darwin//:terraform-provider-matchbox"],
}),
outs = ["bin/terraform-provider-matchbox"],
cmd = "cp $(<) $(@)",
)

exports_files(["config.tf"])

load("@io_bazel_rules_go//go:def.bzl", "go_prefix")

go_prefix("github.com/coreos/tectonic-installer")
Expand All @@ -61,96 +49,54 @@ alias(

alias(
name = "cli",
actual = "//installer/cmd/tectonic:tectonic",
)

load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

# We use a genrule here to combine the tarballs rather than a pkg_tar
# because we want to be able to optionally add a version string to the
# directory name and pkg_tar does not allow for formatted names.
genrule(
name = "tarball",
srcs = [
":tarball_tectonic_binary_darwin",
":tarball_tectonic_binary_linux",
":tarball_terraform_configuration",
":tarball_terraform_binary_darwin",
":tarball_terraform_binary_linux",
":tarball_terraform_provider_matchbox_darwin",
":tarball_terraform_provider_matchbox_linux",
":tarball_examples",
],
outs = ["tectonic.tar.gz"],
cmd = '\n'.join([
"VERSION=$${TECTONIC_VERSION:-}",
"DIR=tectonic",
"[ ! -z $$VERSION ] && DIR=\"$$DIR\"_\"$$VERSION\"",
"TMPDIR=$$(mktemp -d)",
"mkdir $$TMPDIR/$$DIR",
"for s in $(SRCS); do",
"tar -C $$TMPDIR/$$DIR --extract --file $$s --strip-components=1",
"done",
"tar -C $$TMPDIR --create --gzip --file $@ $$DIR"
]),
output_to_bindir = 1,
actual = "//installer:tectonic",
)

pkg_tar(
name = "tarball_terraform_configuration",
mode = "0644",
srcs = glob(["modules/**"]) + glob(["steps/**"]) + ["config.tf"],
strip_prefix = ".",
)
template_files = glob([
"modules/**/*",
"steps/**/*",
"config.tf"
])

pkg_tar(
name = "tarball_tectonic_binary_darwin",
mode = "0755",
package_dir = "tectonic-installer/darwin",
srcs = ["//installer/cmd/tectonic:darwin"],
)
exports_files(template_files)

pkg_tar(
name = "tarball_tectonic_binary_linux",
mode = "0755",
package_dir = "tectonic-installer/linux",
srcs = ["//installer/cmd/tectonic:linux"],
filegroup(
name = "template_resources",
srcs = template_files
)

pkg_tar(
name = "tarball_terraform_binary_darwin",
mode = "0755",
package_dir = "tectonic-installer/darwin",
srcs = ["@terraform_runtime_darwin//:terraform"],
)
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar")

pkg_tar(
name = "tarball_terraform_binary_linux",
mode = "0755",
package_dir = "tectonic-installer/linux",
srcs = ["@terraform_runtime_linux//:terraform"],
alias(
name = "tarball",
actual = ":tectonic-%s" % TECTONIC_VERSION
)

pkg_tar(
name = "tarball_terraform_provider_matchbox_darwin",
mode = "0755",
package_dir = "tectonic-installer/darwin",
srcs = ["@terraform_provider_matchbox_darwin//:terraform-provider-matchbox"],
name = "tectonic-%s" % TECTONIC_VERSION,
strip_prefix = '.',
package_dir = "tectonic-%s" % TECTONIC_VERSION,
extension = "tar.gz",
srcs = [
"//installer:tectonic",
"//:template_resources",
"//examples:tectonic_cli_examples",
],
deps = [":tf_bin"]
)

pkg_tar(
name = "tarball_terraform_provider_matchbox_linux",
mode = "0755",
package_dir = "tectonic-installer/linux",
srcs = ["@terraform_provider_matchbox_linux//:terraform-provider-matchbox"],
filegroup (
name = "terraform_runtime",
srcs = select({
"//:linux": ["@terraform_runtime_linux//:terraform"],
"//:darwin": ["@terraform_runtime_darwin//:terraform"],
})
)

pkg_tar(
name = "tarball_examples",
package_dir = "examples",
# As long as we are not auto-generating the tectonic cli configuration
# examples, make sure to add the manually created once to the tarball.
srcs = ["//examples:tectonic_cli_configs"],
name = "tf_bin",
package_dir = "installer",
srcs = [":terraform_runtime"]
)

filegroup(
Expand All @@ -167,6 +113,6 @@ filegroup(
gen_test(
name = "terraform_fmt",
command = "./bin/terraform fmt -list -check -write=false",
deps = [":terraform_runtime", ":terraform_files"],
deps = [":terraform_runtime_fmt", ":terraform_files"],
size = "small",
)
12 changes: 6 additions & 6 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ pipeline {
bazel build tarball tests/smoke

# Jenkins `stash` does not follow symlinks - thereby temporarily copy the files to the root dir
cp bazel-bin/tectonic.tar.gz .
cp bazel-bin/tectonic-dev.tar.gz .
cp bazel-bin/tests/smoke/linux_amd64_stripped/smoke .
"""
stash name: 'tectonic.tar.gz', includes: 'tectonic.tar.gz'
stash name: 'tectonic-tarball', includes: 'tectonic-dev.tar.gz'
stash name: 'smoke-tests', includes: 'smoke'
archiveArtifacts allowEmptyArchive: true, artifacts: 'tectonic.tar.gz'
archiveArtifacts allowEmptyArchive: true, artifacts: 'tectonic-dev.tar.gz'
}

withDockerContainer(tectonicSmokeTestEnvImage) {
Expand Down Expand Up @@ -239,7 +239,7 @@ pipeline {
withCredentials(quayCreds) {
ansiColor('xterm') {
unstash 'clean-repo'
unstash 'tectonic.tar.gz'
unstash 'tectonic-tarball'
sh """
docker build -t quay.io/coreos/tectonic-installer:master -f images/tectonic-installer/Dockerfile .
docker login -u="$QUAY_ROBOT_USERNAME" -p="$QUAY_ROBOT_SECRET" quay.io
Expand Down Expand Up @@ -305,12 +305,12 @@ def forcefullyCleanWorkspace() {

def unstashCleanRepoTectonicTarGZSmokeTests() {
unstash 'clean-repo'
unstash 'tectonic.tar.gz'
unstash 'tectonic-tarball'
unstash 'smoke-tests'
sh """#!/bin/bash -ex
# Jenkins `stash` does not follow symlinks - thereby temporarily copy the files to the root dir
mkdir -p bazel-bin/tests/smoke/linux_amd64_stripped/
cp tectonic.tar.gz bazel-bin/.
cp tectonic-dev.tar.gz bazel-bin/.
cp smoke bazel-bin/tests/smoke/linux_amd64_stripped/.
"""
}
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ These instructions can be used for AWS:

2. Extract the tarball
```shell
cd bazel-bin
tar -zxf tectonic.tar.gz
cd tectonic
tar -zxf bazel-bin/tectonic-dev.tar.gz
cd tectonic-dev
```

3. Add binaries to $PATH
```shell
export PATH=$(pwd)/tectonic-installer/linux/:$PATH
export PATH=$(pwd)/installer:$PATH
```

4. Edit Tectonic configuration file including the $CLUSTER_NAME
Expand Down
35 changes: 14 additions & 21 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
workspace(name = "tectonic_installer")
workspace(name = "installer")

terrafom_version = "0.11.2"

provider_matchbox_version = "0.2.2"
terrafom_version = "0.11.7"

supported_platforms = [
"linux",
"darwin",
]

# Latest working commit for cross compilation [0] until fix [1] lands.
# [0] https://github.com/bazelbuild/rules_go/issues/1240#issuecomment-357789209
# [1] https://github.com/bazelbuild/rules_go/pull/1248
# We need a feature from recent master to get rid of the platform specific part of the go_binary path.
# https://github.com/bazelbuild/rules_go/pull/1393

git_repository(
name = "io_bazel_rules_go",
remote = "https://github.com/bazelbuild/rules_go.git",
commit = "3f38260eda98d23e9142bb905caede5912508770"
commit = "361556b0d27318d1b8fa42c91a4baa4ab5ea1c58"
)

# http_archive(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mentioned in the comment above. It's because we need a change from bazel-contrib/rules_go#1393 which is not yet released. Once a release is cut, we can revert back to http_archive retrieval. That's why I kept it commented.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once a release is cut, we can revert back to http_archive retrieval.

I've filed openshift/installer#28 with a stab at this.

# name = "io_bazel_rules_go",
# url = "https://github.com/bazelbuild/rules_go/releases/download/0.10.1/rules_go-0.10.1.tar.gz",
# sha256 = "4b14d8dd31c6dbaf3ff871adcd03f28c3274e42abc855cb8fb4d01233c0154dc",
# )

http_archive(
name = "bazel_gazelle",
sha256 = "4952295aa35241082eefbb53decd7d4dd4e67a1f52655d708a1da942e3f38975",
url = "https://github.com/bazelbuild/bazel-gazelle/archive/eaa1e87d2a3ca716780ca6650ef5b9b9663b8773.zip",
strip_prefix = "bazel-gazelle-eaa1e87d2a3ca716780ca6650ef5b9b9663b8773",
url = "https://github.com/bazelbuild/bazel-gazelle/releases/download/0.10.1/bazel-gazelle-0.10.1.tar.gz",
sha256 = "d03625db67e9fb0905bbd206fa97e32ae9da894fe234a493e7517fd25faec914",
)

load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains", "go_repository")
Expand All @@ -44,13 +47,3 @@ gazelle_dependencies()
type = "zip",
url = "https://releases.hashicorp.com/terraform/%s/terraform_%s_%s_amd64.zip" % (terrafom_version, terrafom_version, platform),
) for platform in supported_platforms]

[new_http_archive(
name = "terraform_provider_matchbox_%s" % platform,
build_file_content = """exports_files(
["terraform-provider-matchbox"],
visibility = ["//visibility:public"]
)""",
strip_prefix = "terraform-provider-matchbox-v%s-%s-amd64/" % (provider_matchbox_version, platform),
url = "https://github.com/coreos/terraform-provider-matchbox/releases/download/v%s/terraform-provider-matchbox-v%s-%s-amd64.tar.gz" % (provider_matchbox_version, provider_matchbox_version, platform),
) for platform in supported_platforms]
8 changes: 6 additions & 2 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
example_cli_configs = glob(["tectonic.*.yaml"])

filegroup(
name= "tectonic_cli_configs",
srcs = glob(["tectonic.*.yaml"]),
name= "tectonic_cli_examples",
srcs = example_cli_configs,
visibility = ["//visibility:public"],
)

exports_files(example_cli_configs)
2 changes: 1 addition & 1 deletion images/tectonic-installer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ FROM alpine:3.7
# https://github.com/moby/moby/issues/1676) Make sure to first copy the tarball
# from bazel-bin/tectonic.tar.gz to the docker build context folder of your
# choice (e.g. the root of the repository).
ADD tectonic.tar.gz /
ADD tectonic-dev.tar.gz /
26 changes: 26 additions & 0 deletions installer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

test_suite(
name = "cli_units",
tests = [
Expand All @@ -7,3 +9,27 @@ test_suite(
"//installer/pkg/workflow:go_default_test",
],
)

go_library(
name = "go_default_library",
srcs = [
"cmd/tectonic/main.go",
],
visibility = ["//visibility:private"],
deps = [
"//installer/pkg/workflow:go_default_library",
"//installer/vendor/github.com/Sirupsen/logrus:go_default_library",
"//installer/vendor/gopkg.in/alecthomas/kingpin.v2:go_default_library",
],
)

go_binary(
name = "tectonic",
out = "tectonic",
embed = [":go_default_library"],
# Use pure to build a pure-go binary.
# This has the nice side effect of making the binary statically linked.
pure = "on",
visibility = ["//visibility:public"],
data = ["//:template_resources"]
)
51 changes: 0 additions & 51 deletions installer/cmd/tectonic/BUILD.bazel

This file was deleted.

Loading