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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,14 @@ updates:
- "junit:*"
- "org.mockito:*"
open-pull-requests-limit: 7
# Maven in /gtfs/pom.xml
- package-ecosystem: "maven"
directory: "/gtfs"
schedule:
interval: "weekly"
day: "wednesday"
time: "16:00"
timezone: "America/Montreal"
assignees:
- "montransit"
open-pull-requests-limit: 7
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
*.iml

# TOML Dependency updater file
*.updates.toml
*.updates.toml

# Gradle local caches and build outputs
shared/.gradle/
shared/build/
Binary file removed gtfs/gtfs-validator-8.0.0-cli.jar
Binary file not shown.
37 changes: 34 additions & 3 deletions gtfs/gtfs-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,40 @@ fi
# gh release list --limit 1 --repo github.com/MobilityData/gtfs-validator;
# echo "> GTFS Validator latest release... DONE";

JAR_FILE_PATTERN="$SCRIPT_DIR/gtfs-validator-*.jar";
JAR_FILES=($JAR_FILE_PATTERN);
JAR_FILE="${JAR_FILES[0]}";
VERSION_FILE="$SCRIPT_DIR/pom.xml";
if [ ! -f "$VERSION_FILE" ]; then
echo "> GTFS Validator version file '$VERSION_FILE' not found!";
exit 1;
fi
GTFS_VALIDATOR_VERSION=$(sed -n 's/.*<gtfs.validator.version>\([^<]*\)<\/gtfs.validator.version>.*/\1/p' "$VERSION_FILE" | head -n 1 | tr -d '[:space:]');
if [ -z "$GTFS_VALIDATOR_VERSION" ]; then
echo "> GTFS Validator version not found in '$VERSION_FILE'!";
exit 1;
fi
JAR_FILE="$SCRIPT_DIR/gtfs-validator-$GTFS_VALIDATOR_VERSION-cli.jar";
if [ ! -s "$JAR_FILE" ]; then
rm -f "$JAR_FILE";
if ! command -v gh >/dev/null 2>&1; then
echo "> GitHub CLI (gh) is required to download GTFS Validator '$GTFS_VALIDATOR_VERSION' (https://cli.github.com/)!";
exit 1;
fi
echo "> Downloading GTFS Validator '$GTFS_VALIDATOR_VERSION'...";
gh release download "v$GTFS_VALIDATOR_VERSION" \
--repo MobilityData/gtfs-validator \
--pattern "gtfs-validator-$GTFS_VALIDATOR_VERSION-cli.jar" \
--dir "$SCRIPT_DIR";
Comment on lines +43 to +51

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using gh release download introduces an unnecessary dependency on the GitHub CLI (gh) and requires the user to be authenticated with GitHub (even for public repositories, gh often fails or hits rate limits if not authenticated). Since the release assets of MobilityData/gtfs-validator are publicly accessible via standard HTTPS URLs, using curl is much more portable, standard, and works out-of-the-box in almost any environment (local or CI) without requiring any authentication or extra tool installation.

Suggested change
if ! command -v gh >/dev/null 2>&1; then
echo "> GitHub CLI (gh) is required to download GTFS Validator '$GTFS_VALIDATOR_VERSION' (https://cli.github.com/)!";
exit 1;
fi
echo "> Downloading GTFS Validator '$GTFS_VALIDATOR_VERSION'...";
gh release download "v$GTFS_VALIDATOR_VERSION" \
--repo MobilityData/gtfs-validator \
--pattern "gtfs-validator-$GTFS_VALIDATOR_VERSION-cli.jar" \
--dir "$SCRIPT_DIR";
if ! command -v curl >/dev/null 2>&1; then
echo "> curl is required to download GTFS Validator '$GTFS_VALIDATOR_VERSION'!";
exit 1;
fi
echo "> Downloading GTFS Validator '$GTFS_VALIDATOR_VERSION'...";
curl -L -f -s -S -o "$JAR_FILE" "https://github.com/MobilityData/gtfs-validator/releases/download/v$GTFS_VALIDATOR_VERSION/gtfs-validator-$GTFS_VALIDATOR_VERSION-cli.jar";

DOWNLOAD_RESULT=$?;
if [[ ${DOWNLOAD_RESULT} -ne 0 ]]; then
echo "> Error while downloading GTFS Validator '$GTFS_VALIDATOR_VERSION'!";
exit ${DOWNLOAD_RESULT};
fi
if [ ! -s "$JAR_FILE" ]; then
echo "> Downloaded GTFS Validator JAR '$JAR_FILE' is missing or empty!";
exit 1;
fi
echo "> Downloading GTFS Validator '$GTFS_VALIDATOR_VERSION'... DONE";
fi
echo "> GTFS Validator version: '$GTFS_VALIDATOR_VERSION'.";
echo "> GTFS Validator JAR file: '$JAR_FILE'.";

echo "> Launching GTFS Validator...";
Expand Down
22 changes: 22 additions & 0 deletions gtfs/pom.xml
Comment thread
mmathieum marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.mtransitapps.commons</groupId>
<artifactId>gtfs-validator-version</artifactId>
<version>1.0.0</version>

<properties>
<gtfs.validator.version>8.0.1</gtfs.validator.version>
</properties>

<dependencies>
<dependency>
<groupId>org.mobilitydata</groupId>
<artifactId>gtfs-validator</artifactId>
<version>${gtfs.validator.version}</version>
</dependency>
</dependencies>
</project>