Skip to content
Open
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
7 changes: 6 additions & 1 deletion .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ jobs:

# Scheduled run: check if latest releases are already published on the site
CF_TAG=$(gh api repos/eisop/checker-framework/releases --jq '.[0].tag_name')
AFU_ZIP=$(gh api repos/eisop/annotation-tools/releases --jq '.[0].assets[0].name')
# The Annotation File Utilities zip is an asset of the Checker Framework release.
# Older releases are in the former annotation-tools repository.
AFU_ZIP=$(gh api repos/eisop/checker-framework/releases --jq '[.[].assets[] | select(.name | startswith("annotation-file-utilities-"))] | .[0].name')
if [ -z "$AFU_ZIP" ] || [ "$AFU_ZIP" = "null" ]; then
AFU_ZIP=$(gh api repos/eisop/annotation-tools/releases --jq '.[0].assets[0].name')
fi

CF_STATUS=$(curl -s -o /dev/null -w '%{http_code}' "https://eisop.github.io/cf/${CF_TAG}/index.html")
AFU_STATUS=$(curl -s -o /dev/null -w '%{http_code}' "https://eisop.github.io/afu/${AFU_ZIP}")
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The website is updated automatically via a daily GitHub Actions schedule that
checks if new Checker Framework or Annotation File Utilities releases have been
published. If new releases exist, it generates and publishes the pages.

A release of the Checker Framework has two zip assets,
`checker-framework-VERSION.zip` and `annotation-file-utilities-VERSION.zip`.
The former repository `eisop/annotation-tools` is archived; its releases,
with zips named `annotation-tools-VERSION.zip`, are used for the Annotation File Utilities versions before the first release
of the Checker Framework that has the second asset.

You can also run the **Publish website** workflow manually from the Actions tab.
It checks out `master` for the generator, builds it, checks out `gh-pages`,
downloads any release that is not on the site yet, regenerates the pages, and pushes.
Expand Down
107 changes: 69 additions & 38 deletions src/main/java/io/github/eisop/website/EisopSiteGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ public static void main(String[] args) throws IOException {
for (int i = 0; i < limit; i++) {
boolean isLocalRelease = (i == 0 && localReleaseZip != null);

// A release has other assets as well, such as the Annotation File Utilities zip.
JSONObject latestAssetsData =
findZipAsset((JSONObject) frameworkReleases.get(i), "checker-framework-");
if (latestAssetsData == null) {
System.out.println(
"Skipping release without a Checker Framework zip: "
+ ((JSONObject) frameworkReleases.get(i)).get("tag_name"));
continue;
}

if (!isLocalRelease) {
releaseFileHTML +=
"["
Expand All @@ -138,11 +148,6 @@ public static void main(String[] args) throws IOException {
+ "/index.html)\n";
}

// Get data on release assets
JSONObject latestAssetsData =
(JSONObject)
((((JSONArray) ((JSONObject) frameworkReleases.get(i)).get("assets"))
.get(0)));
int connectTimeout = 0;
int readTimeout = 0;
String fileUrlString = String.valueOf(latestAssetsData.get("browser_download_url"));
Expand Down Expand Up @@ -314,13 +319,7 @@ public static void main(String[] args) throws IOException {
latestCheckerFrameworkReleaseDownloadLink);

String latestCheckerFrameworkReleaseDate =
String.valueOf(
((JSONObject)
((((JSONArray)
((JSONObject) frameworkReleases.get(i))
.get("assets"))
.get(0))))
.get("created_at"));
String.valueOf(latestAssetsData.get("created_at"));
latestCheckerFrameworkReleaseDate = getReadableDate(latestCheckerFrameworkReleaseDate);
htmlString =
htmlString.replace(
Expand Down Expand Up @@ -491,6 +490,28 @@ static JSONArray getAPIResponse(URL apiURL) throws IOException {
}
}

/**
* Returns the zip asset of the given release whose name starts with the given prefix.
*
* @param release a GitHub release
* @param prefix the start of the name of the asset
* @return the asset, or null if the release has none
*/
static JSONObject findZipAsset(JSONObject release, String prefix) {
JSONArray assets = (JSONArray) release.get("assets");
if (assets == null) {
return null;
}
for (Object assetObject : assets) {
JSONObject asset = (JSONObject) assetObject;
String name = String.valueOf(asset.get("name"));
if (name.startsWith(prefix) && name.endsWith(".zip")) {
return asset;
}
}
return null;
}

static void getAFU(boolean onlyLatest) throws IOException {
File directoryPath = new File(System.getProperty("user.dir") + "/afu");
if (!directoryPath.exists()) {
Expand All @@ -503,21 +524,41 @@ static void getAFU(boolean onlyLatest) throws IOException {
System.out.println("Folder already exists at: " + directoryPath);
}

// Get list of framework releases
URL listReleasesURL =
URI.create(
"https://api.github.com/repos/eisop/annotation-tools/releases?per_page=100")
.toURL();
JSONArray frameworkReleases = getAPIResponse(listReleasesURL);
// Get the releases of the Annotation File Utilities. Since the Annotation File Utilities
// became part of the Checker Framework repository, each Checker Framework release has an
// annotation-tools-VERSION.zip asset. Older releases are in the former repository.
// The releases are ordered from the newest to the oldest.
List<JSONObject> afuAssets = new ArrayList<>();
// The zips of the former repository are named annotation-tools-VERSION.zip, and the zips of
// the Checker Framework releases are named annotation-file-utilities-VERSION.zip.
for (String repo : new String[] {"checker-framework", "annotation-tools"}) {
URL listReleasesURL =
URI.create(
"https://api.github.com/repos/eisop/"
+ repo
+ "/releases?per_page=100")
.toURL();
JSONArray releases = getAPIResponse(listReleasesURL);
for (Object release : releases) {
JSONObject afuAsset =
findZipAsset((JSONObject) release, "annotation-file-utilities-");
if (afuAsset == null) {
afuAsset = findZipAsset((JSONObject) release, "annotation-tools-");
}
if (afuAsset != null) {
afuAssets.add(afuAsset);
}
}
}
if (afuAssets.isEmpty()) {
throw new IOException("No Annotation File Utilities release found.");
}

// Loop through list of framework releases
int limit = onlyLatest ? 1 : frameworkReleases.size();
// Loop through the list of Annotation File Utilities releases
int limit = onlyLatest ? 1 : afuAssets.size();
for (int i = 0; i < limit; i++) {
// Get data on release assets
JSONObject latestAssetsData =
(JSONObject)
((((JSONArray) ((JSONObject) frameworkReleases.get(i)).get("assets"))
.get(0)));
JSONObject latestAssetsData = afuAssets.get(i);
int connectTimeout = 0;
int readTimeout = 0;
String fileUrlString = String.valueOf(latestAssetsData.get("browser_download_url"));
Expand Down Expand Up @@ -557,13 +598,7 @@ static void getAFU(boolean onlyLatest) throws IOException {
if (globalIndexHTML.exists()) {
FileUtils.forceDelete(globalIndexHTML);
}
String latestReleaseZipName =
String.valueOf(
((JSONObject)
((JSONArray) ((JSONObject) frameworkReleases.get(0))
.get("assets"))
.get(0))
.get("name"));
String latestReleaseZipName = String.valueOf(afuAssets.get(0).get("name"));
String latestReleaseName =
latestReleaseZipName.substring(0, latestReleaseZipName.length() - 4);

Expand Down Expand Up @@ -611,13 +646,7 @@ static void getAFU(boolean onlyLatest) throws IOException {
"/afu/" + latestAnnotationFileUtilitiesReleaseZip;

String latestAnnotationFileUtilitiesReleaseDate =
String.valueOf(
((JSONObject)
((((JSONArray)
((JSONObject) frameworkReleases.get(0))
.get("assets"))
.get(0))))
.get("created_at"));
String.valueOf(afuAssets.get(0).get("created_at"));
latestAnnotationFileUtilitiesReleaseDate =
getReadableDate(latestAnnotationFileUtilitiesReleaseDate);

Expand All @@ -634,6 +663,8 @@ static void getAFU(boolean onlyLatest) throws IOException {
String[] parts = latestReleaseName.split("-");
String latestAnnotationFileUtilitiesRelease = parts[parts.length - 2];

// The name of the release, such as annotation-tools-1.2.3-eisop1.
mdString = mdString.replace("$LatestAnnotationFileUtilitiesReleaseName", latestReleaseName);
mdString =
mdString.replace(
"$LatestAnnotationFileUtilitiesReleaseDate",
Expand Down
18 changes: 8 additions & 10 deletions src/main/resources/afu-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,26 @@ The following instructions assume either a Linux or Windows system using a comma
The current release is Annotation File Utilities version $LatestAnnotationFileUtilitiesRelease, $LatestAnnotationFileUtilitiesReleaseDate.

1. Download [$LatestAnnotationFileUtilitiesReleaseZip]($LatestAnnotationFileUtilitiesReleaseDownloadLink).
2. Create a directory named `annotation-tools` by unpacking the distribution zipfile. (You will typically make `annotation-tools/` a sibling of `checker-framework/`.)
2. Unpack the distribution zipfile, which creates a directory named `$LatestAnnotationFileUtilitiesReleaseName`.

unzip annotation-tools-$LatestAnnotationFileUtilitiesRelease.zip
unzip $LatestAnnotationFileUtilitiesReleaseName.zip

3. Add the `annotation-file-utilities` directory to your path.
3. Add the `annotation-file-utilities/bin` directory to your path.
* For **Unix** (including Linux and MacOS), add the directory to your PATH environment variable. If your shell is sh or bash, add to your `~/.bashrc` or `~/.bash_profile` file:

export PATH=${PATH}:/path/to/annotation-tools/annotation-file-utilities/scripts
export PATH=${PATH}:/path/to/$LatestAnnotationFileUtilitiesReleaseName/annotation-file-utilities/bin

* For **Windows**, add the directory to your `PATH` system variable by going to

Control Panel -> System -> Advanced -> Environment Variables

From there, find the `PATH` variable under “System variables” and append to it the directory `_path\to_\annotation-tools\annotation-file-utilities\scripts`.
From there, find the `PATH` variable under “System variables” and append to it the directory `_path\to_\$LatestAnnotationFileUtilitiesReleaseName\annotation-file-utilities\bin`.

### Building from source

The annotation file utilities are pre-compiled (a jar file is included in the distribution), so most users do not need to compile it themselves.

There are two ways to obtain the source code. Source code is provided in the [distribution](https://github.com/eisop/annotation-tools/releases). Alternately, see the source code repository at [https://github.com/eisop/annotation-tools](https://github.com/eisop/annotation-tools).
The source code is in the `annotation-file-utilities` directory of the [EISOP Checker Framework repository](https://github.com/eisop/checker-framework). The Annotation File Utilities are also available from Maven Central, as `io.github.eisop:annotation-file-utilities`. The former repository, [eisop/annotation-tools](https://github.com/eisop/annotation-tools), is archived.

To compile and run tests, do `./gradlew build` from the `annotation-file-utilities` subdirectory.

Expand Down Expand Up @@ -258,12 +258,10 @@ If there are remaining `Insertion`s that were not matched to a node in the abstr
Feedback and bug reports
------------------------

To submit a bug report or request a new feature, use the [issue tracker](https://github.com/eisop/annotation-tools/issues). When reporting a bug, please include exact instructions on how to reproduce it, and please also attach relevant input files. This will let us resolve the issue quickly.

You can also reach the developers at [annotation-tools-dev@googlegroups.com](mailto:annotation-tools-dev@googlegroups.com). But please use the [issue tracker](https://github.com/eisop/annotation-tools/issues) for bug reports and feature requests.
To submit a bug report or request a new feature, use the [issue tracker](https://github.com/eisop/checker-framework/issues). When reporting a bug, please include exact instructions on how to reproduce it, and please also attach relevant input files. This will let us resolve the issue quickly.

### Changelog

The [changelog](changelog.html) describes what is new in each release.
The [changelog](changelog.html) describes what is new in each release up to 3.49.5-eisop1. Later changes are in the [Checker Framework changelog](https://github.com/eisop/checker-framework/blob/master/docs/CHANGELOG.md).

* * *
2 changes: 1 addition & 1 deletion src/main/resources/cf-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The Checker Framework enhances Java's type system to make it more powerful and u
* Optional related tools:
* The [**Annotation File Utilities**](../afu/annotation-file-utilities.md) extract annotations from, and write annotations to, `.java` and `.class` files. It also provides a representation (called an “annotation file”) for annotations that is outside the source code or the `.class` file. The tools support both Java 5 declaration annotations and Java 8 type annotations.
* [$LatestAnnotationFileUtilitiesReleaseZip]($LatestAnnotationFileUtilitiesReleaseDownloadLink) ($LatestAnnotationFileUtilitiesReleaseDate)
* [source code repository](https://github.com/eisop/annotation-tools/)
* [source code](https://github.com/eisop/checker-framework/tree/master/annotation-file-utilities)
* [Documentation](../afu/annotation-file-utilities.html) is included in the zip archive and in the repository.
* [Archive of previous releases](releases/releases.html) of the Checker Framework
* Research papers: See the [Checker Framework manual](manual/manual.html#publications)
Expand Down
Loading