Skip to content

Commit ea39ece

Browse files
committed
deploy: Inject Jazzer version via a flag
This removes the need to have a "version bump" commit before every release.
1 parent 9b58301 commit ea39ece

File tree

12 files changed

+181
-54
lines changed

12 files changed

+181
-54
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ build:ci --noslim_profile
8080
build:ci --experimental_profile_include_target_label
8181
build:ci --experimental_profile_include_primary_output
8282
build:ci --nolegacy_important_outputs
83+
common:ci --announce_rc
8384

8485
# Docker images
8586
common:docker --config=toolchain

.github/workflows/prerelease.yaml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Pre-Release
22

33
on:
44
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v*'
58

69
jobs:
710
build_release:
@@ -25,14 +28,13 @@ jobs:
2528
distribution: zulu
2629
java-version: 8
2730

28-
- name: Set Build Buddy config
29-
shell: bash
30-
run: .github/scripts/echoBuildBuddyConfig.sh ${{ secrets.BUILDBUDDY_API_KEY }} >> $GITHUB_ENV
31-
3231
- name: Append build settings to .bazelrc
3332
shell: bash
3433
run: |
35-
echo "build --announce_rc" >> .bazelrc
34+
TAG=${{ github.ref_name }}
35+
echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}" >> .bazelrc
36+
echo "build --config=ci" >> .bazelrc
37+
echo "build --//deploy:jazzer_version=${TAG#v}" >> .bazelrc
3638
echo "build:linux --config=toolchain" >> .bazelrc
3739
echo "build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux" >> .bazelrc
3840
@@ -86,7 +88,9 @@ jobs:
8688
if-no-files-found: error
8789

8890
maven_predeploy:
89-
runs-on: ubuntu-latest
91+
# TODO: Our hermetic toolchain doesn't support ubuntu-latest yet and fails with:
92+
# external/llvm_toolchain_llvm/bin/clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
93+
runs-on: ubuntu-20.04
9094
needs: merge_jars
9195

9296
environment:
@@ -95,6 +99,22 @@ jobs:
9599
steps:
96100
- uses: actions/checkout@v3
97101

102+
- name: Set up JDK
103+
uses: actions/setup-java@v3
104+
with:
105+
distribution: zulu
106+
java-version: 8
107+
108+
- name: Append build settings to .bazelrc
109+
shell: bash
110+
run: |
111+
TAG=${{ github.ref_name }}
112+
echo "build --remote_header=x-buildbuddy-api-key=${{ secrets.BUILDBUDDY_API_KEY }}" >> .bazelrc
113+
echo "build --config=ci" >> .bazelrc
114+
echo "build --//deploy:jazzer_version=${TAG#v}" >> .bazelrc
115+
echo "build:linux --config=toolchain" >> .bazelrc
116+
echo "build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux" >> .bazelrc
117+
98118
- name: Download merged jar
99119
uses: actions/download-artifact@v3
100120
with:
@@ -126,18 +146,9 @@ jobs:
126146
name: jazzer_releases
127147
path: _releases/
128148

129-
- name: read version
130-
id: read-version
131-
run: |
132-
echo ::set-output name=version::\
133-
$(sed -nr 's/JAZZER_VERSION = "(.*)"/\1/p' maven.bzl)
134-
shell: bash
135-
136149
- name: create release
137-
uses: softprops/action-gh-release@v1
150+
uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d
138151
with:
139-
name: v${{ steps.read-version.outputs.version }}
140-
tag_name: v${{ steps.read-version.outputs.version }}
141152
generate_release_notes: true
142153
draft: true
143154
files: |

CONTRIBUTING.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ Run `./format.sh` to format all source files in the way enforced by the "Check f
7070

7171
## Releasing (CI employees only)
7272

73-
1. Update `JAZZER_VERSION` in [`maven.bzl`](maven.bzl).
74-
2. Trigger the "Prerelease" GitHub Actions workflow for the branch where you want to do the release:
75-
* `main` for major and minor releases
76-
* An appropriate release branch for patch releases
77-
3. Wait for the workflow to finish (about 10 minutes)
78-
4. When successful and happy with the results, log into https://oss.sonatype.org, select both staging repositories and "Close" them.
73+
1. Push a tag of the form `v1.2.3` to trigger the "Prerelease" GitHub Actions workflow.
74+
2. Wait for the workflow to finish (about 10 minutes)
75+
3. When successful and happy with the results, log into https://oss.sonatype.org, select all three staging repositories (under "Repositories" -> "Staging" -> `com/code_intelligence`) and "Close" them.
7976
Wait and refresh, then select them again and "Release" them.
80-
5. Release the draft Github release. This will automatically create a tag, push the docker images and deploy the docs (can take about a few minutes to appear at [jazzer-docs]( https://codeintelligencetesting.github.io/jazzer-docs)).
77+
4. Release the draft Github release. This will automatically create a tag, push the docker images and deploy the docs (can take about a few minutes to appear at [jazzer-docs]( https://codeintelligencetesting.github.io/jazzer-docs)).

deploy/BUILD.bazel

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
1+
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
12
load("@rules_jvm_external//:defs.bzl", "java_export")
2-
load("//:maven.bzl", "JAZZER_API_COORDINATES", "JAZZER_COORDINATES", "JAZZER_JUNIT_COORDINATES")
33
load("//bazel:compat.bzl", "SKIP_ON_WINDOWS")
44

5+
JAZZER_COORDINATES = "com.code-intelligence:jazzer:$(JAZZER_VERSION)"
6+
57
sh_binary(
68
name = "deploy",
79
srcs = ["deploy.sh"],
810
args = [JAZZER_COORDINATES],
911
data = ["@bazel_tools//tools/jdk:current_host_java_runtime"],
1012
env = {"JAVA_EXECPATH": "$(JAVA)"},
11-
toolchains = ["@bazel_tools//tools/jdk:current_host_java_runtime"],
13+
toolchains = [
14+
"@bazel_tools//tools/jdk:current_host_java_runtime",
15+
":jazzer_version",
16+
],
1217
deps = ["@bazel_tools//tools/bash/runfiles"],
1318
)
1419

20+
string_flag(
21+
name = "jazzer_version",
22+
build_setting_default = "0.0.0-dev",
23+
make_variable = "JAZZER_VERSION",
24+
visibility = ["//visibility:public"],
25+
)
26+
1527
java_export(
1628
name = "jazzer-api",
1729
doc_url = "https://codeintelligencetesting.github.io/jazzer-docs/jazzer-api/",
1830
javadocopts = [
1931
"-link",
2032
"https://docs.oracle.com/en/java/javase/17/docs/api/",
2133
],
22-
maven_coordinates = JAZZER_API_COORDINATES,
34+
maven_coordinates = "com.code-intelligence:jazzer-api:$(JAZZER_VERSION)",
2335
pom_template = "//deploy:jazzer-api.pom",
36+
toolchains = [":jazzer_version"],
2437
visibility = ["//visibility:public"],
2538
runtime_deps = ["//src/main/java/com/code_intelligence/jazzer/api"],
2639
)
@@ -32,6 +45,7 @@ java_export(
3245
# Do not generate an implicit javadocs target - the current target is based on the shaded deploy
3346
# JAR, for which the docs JAR generated by default would be empty.
3447
tags = ["no-javadocs"],
48+
toolchains = [":jazzer_version"],
3549
visibility = ["//visibility:public"],
3650
runtime_deps = [
3751
"//src/main/java/com/code_intelligence/jazzer:jazzer_import",
@@ -64,8 +78,9 @@ java_export(
6478
"-link",
6579
"https://junit.org/junit5/docs/current/api/",
6680
],
67-
maven_coordinates = JAZZER_JUNIT_COORDINATES,
81+
maven_coordinates = "com.code-intelligence:jazzer-junit:$(JAZZER_VERSION)",
6882
pom_template = "jazzer-junit.pom",
83+
toolchains = [":jazzer_version"],
6984
visibility = ["//visibility:public"],
7085
runtime_deps = [
7186
# These deps' only effect is to include a dependency on the 'jazzer' and 'jazzer-api' Maven artifacts in the

deploy/deploy.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ fail() {
2222

2323
cd "$BUILD_WORKSPACE_DIRECTORY" || fail "BUILD_WORKSPACE_DIRECTORY not found"
2424

25+
JAZZER_COORDINATES=$1
26+
[[ "$JAZZER_COORDINATES" != *-dev ]] || fail "--//deploy:jazzer_version must be set to a release version, got: $JAZZER_COORDINATES"
27+
2528
echo "$RELEASE_SIGNING_KEY_PRIVATE" | gpg --import
2629
echo "default-key $RELEASE_SIGNING_KEY_ID" > $HOME/.gnupg/gpg.conf
2730

28-
JAZZER_COORDINATES=$1
29-
3031
[ -z "${MAVEN_USER+x}" ] && \
3132
fail "Set MAVEN_USER to the Sonatype OSSRH user"
3233
[ -z "${MAVEN_PASSWORD+x}" ] && \

deploy/jazzer_version_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jazzer=$(rlocation "$JAZZER_RLOCATIONPATH")
3232
[ -f "$jazzer" ] || exit 1
3333
jazzer_version_output=$("$java" -jar "$jazzer" --version 2>&1)
3434
echo "$jazzer_version_output"
35-
echo "$jazzer_version_output" | tr -d '\n' | grep -q '^Jazzer v[0-9.]*$' || exit 1
35+
echo "$jazzer_version_output" | tr -d '\n' | grep -q '^Jazzer v0.0.0-dev$' || exit 1

examples/junit-spring-web/build-and-run-tests.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ set -e
2121
bazel build //deploy:all
2222
)
2323

24-
# Update jazzer version used for building this project in the pom.xml
25-
JAZZER_VERSION=$(grep -oP '(?<=JAZZER_VERSION = ")[^"]*' ../../maven.bzl)
26-
# Find line with "<artifactId>jazzer-junit</artifactId>" and replace the version in the next line
27-
sed -i "/<artifactId>jazzer-junit<\/artifactId>/ {n;s/<version>.*<\/version>/<version>$JAZZER_VERSION<\/version>/}" pom.xml
28-
2924
# Add locally-built Jazzer to the Maven repository
3025
./mvnw install:install-file -Dfile=../../bazel-bin/deploy/jazzer-junit-project.jar -DpomFile=../../bazel-bin/deploy/jazzer-junit-pom.xml
3126
./mvnw install:install-file -Dfile=../../bazel-bin/deploy/jazzer-project.jar -DpomFile=../../bazel-bin/deploy/jazzer-pom.xml

examples/junit-spring-web/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>com.code-intelligence</groupId>
5252
<artifactId>jazzer-junit</artifactId>
53-
<version>0.16.1</version>
53+
<version>0.0.0-dev</version>
5454
<scope>test</scope>
5555
</dependency>
5656
<dependency>

maven.bzl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414

1515
load("@rules_jvm_external//:specs.bzl", "maven")
1616

17-
JAZZER_VERSION = "0.21.0"
18-
JAZZER_COORDINATES = "com.code-intelligence:jazzer:%s" % JAZZER_VERSION
19-
JAZZER_API_COORDINATES = "com.code-intelligence:jazzer-api:%s" % JAZZER_VERSION
20-
JAZZER_JUNIT_COORDINATES = "com.code-intelligence:jazzer-junit:%s" % JAZZER_VERSION
21-
2217
# keep sorted
2318
MAVEN_ARTIFACTS = [
2419
"org.junit.jupiter:junit-jupiter-api:5.9.0",

repositories.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ def jazzer_dependencies(android = False):
3232
maybe(
3333
http_archive,
3434
name = "bazel_skylib",
35-
sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
35+
sha256 = "ade20530fd2d39abb49d537e77d4d873a823649b6061e0bb0c369b34450909d6",
36+
strip_prefix = "bazel-skylib-8386b9d32bf69dd2d2f92d9ca39582cf6dabeb37",
37+
# TODO: Return to the next release.
3638
urls = [
37-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
38-
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
39+
"https://github.com/bazelbuild/bazel-skylib/archive/8386b9d32bf69dd2d2f92d9ca39582cf6dabeb37.tar.gz",
3940
],
4041
)
4142

@@ -63,6 +64,10 @@ def jazzer_dependencies(android = False):
6364
# https://github.com/bazelbuild/rules_jvm_external/pull/958
6465
# Allows javadoc targets to reference other javadoc targets.
6566
"//third_party:rules_jvm_external-javadoc-deps.patch",
67+
# https://github.com/bazelbuild/rules_jvm_external/pull/960
68+
# Forwards the toolchains attribute on java_export to all underlying targets and
69+
# evaluates Make variables from deps in pom_file.
70+
"//third_party:rules_jvm_external-toolchains-attribute.patch",
6671
],
6772
sha256 = "aa17db9b810b22e411bf722095be34eeb66c76819b9c3423ad7740f452016aa3",
6873
strip_prefix = "rules_jvm_external-4b073de468eff9741406f475acb04e94bee7c9d0",

0 commit comments

Comments
 (0)