Remove more flex tests #1055
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: OTP CI Build | |
on: | |
push: | |
pull_request: | |
branches: | |
- ibi-dev | |
- ibi-dev-2.x | |
jobs: | |
build-linux: | |
env: | |
MAVEN_OPTS: -Xmx2g | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
steps: | |
# Starting in v2.2 checkout action fetches all tags when fetch-depth=0, for auto-versioning. | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# nodejs is needed because the dynamic download of it via the prettier maven plugin often | |
# times out | |
# Example: https://github.com/opentripplanner/OpenTripPlanner/actions/runs/4490450225/jobs/7897533439 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
# Java setup step completes very fast, no need to run in a preconfigured docker container. | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: maven | |
- name: Prepare coverage agent, build and test | |
# these are split into two steps because otherwise maven keeps long-running HTTP connections | |
# to Maven Central open which then hang during the package phase because the Azure (Github Actions) | |
# NAT drops them | |
# https://github.com/actions/runner-images/issues/1499 | |
# we set nodePath and npmPath to skip downloading the node binary, which frequently times out | |
run: | | |
mvn --batch-mode jacoco:prepare-agent test jacoco:report -P prettierCheck,unit-tests -Dprettier.nodePath=node -Dprettier.npmPath=npm | |
mvn --batch-mode package -Dmaven.test.skip -P prettierSkip | |
- name: Send coverage data to codecov.io | |
if: github.repository_owner == 'opentripplanner' | |
uses: codecov/codecov-action@v4 | |
with: | |
files: target/site/jacoco/jacoco.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true | |
- name: Deploy to Github Package Registry | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev-1.x' || github.ref == 'refs/heads/dev-2.x') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: mvn --batch-mode deploy --settings maven-settings.xml -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY -P prettierSkip -P deployGitHub | |
## IBI start | |
# So that the branch name can be reference via $GITHUB_REF_SLUG. | |
- name: Inject slug/short variables | |
uses: rlespinasse/[email protected] | |
# Define AWS profile credentials for use by subsequent steps. | |
- name: Add profile credentials to ~/.aws/credentials | |
if: github.event_name == 'push' | |
run: ./scripts/add-aws-credentials.sh | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
# Only prepare deploy files on push events to avoid duplicate pushes to s3 when a commit is | |
# pushed to a branch with an open pull request. | |
- name: Prepare build files for deployment to s3 | |
if: github.event_name == 'push' | |
run: ./scripts/prep-build-for-deploy-from-github-actions.sh | |
# Copy build files to AWS. | |
- name: Copy build files to the otp-repo bucket | |
if: github.event_name == 'push' | |
run: | | |
aws s3 cp ./deploy s3://otp-repo --recursive --acl public-read | |
# Install mkdocs using pip for use by subsequent steps. | |
- name: Install mkdocs | |
if: github.event_name == 'push' && env.GITHUB_REF_SLUG == 'ibi-dev-2.x' | |
run: | | |
pip install mkdocs | |
# Using mkdocs produce docs for deployment. | |
# FIXME: there is an error while trying to run enunciate to generate the docs | |
# - name: Prepare doc files for deployment to s3 | |
# if: github.event_name == 'push' && env.GITHUB_REF_SLUG == 'ibi-dev-2.x' | |
# run: ./scripts/prep-docs-for-deploy-from-github-actions.sh | |
# # If on ibi-dev branch, then upload docs to IBI s3 buckets & cloudfront. | |
# FIXME: figure out whether the same bucket should be used, or a different one should be used for 2.x docs | |
# - name: Upload docs to IBI s3 buckets & cloudfront | |
# if: github.event_name == 'push' && env.GITHUB_REF_SLUG == 'ibi-dev-2.x' | |
# run: | | |
# aws s3 cp ./target/mkdocs s3://otp-docs.ibi-transit.com --recursive --acl public-read | |
# Push notification to Teams. | |
- name: Notify us of the build status on MS Teams | |
# Release https://github.com/toko-bifrost/ms-teams-deploy-card/releases/tag/3.1.2 this matches | |
# the full length commit SHA below. This must not be changed without first reviewing the code of the newer | |
# version for potential security risks. | |
uses: toko-bifrost/ms-teams-deploy-card@dcc94e4ce4088b1e6b6de5c9a3cda4ddcbe97d2e | |
if: always() | |
with: | |
github-token: ${{ github.token }} | |
webhook-uri: ${{ secrets.MSTEAMS_WEBHOOK }} | |
build-windows: | |
timeout-minutes: 20 | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: maven | |
# on windows there are frequent failures caused by page files being too small | |
# https://github.com/actions/virtual-environments/issues/785 | |
- name: Configure Windows Pagefile | |
uses: al-cheb/[email protected] | |
- name: Run tests | |
run: mvn --batch-mode test -P prettierSkip | |
docs: | |
if: github.repository_owner == 'opentripplanner' | |
runs-on: ubuntu-latest | |
env: | |
REMOTE: docs | |
LOCAL_BRANCH: local-pages | |
REMOTE_BRANCH: main | |
TOKEN: ${{ secrets.CHANGELOG_TOKEN }} | |
MASTER_BRANCH_VERSION: 2.5.0 | |
steps: | |
- uses: actions/checkout@v4 | |
# this is necessary so that the correct credentials are put into the git configuration | |
# when we push to dev-2.x and push the HTML to the git repo | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master') | |
with: | |
token: ${{ secrets.CHANGELOG_TOKEN }} | |
# fetch a large-ish number of commits so that we can check when the GraphQL schema file | |
# was modified last | |
fetch-depth: 1000 | |
- uses: actions/checkout@v4 | |
# for a simple PR where we don't push, we don't need any credentials | |
if: github.event_name == 'pull_request' | |
- name: Install Python dependencies | |
run: pip install -r doc/user/requirements.txt | |
- name: Build main documentation | |
if: github.event_name == 'pull_request' | |
run: mkdocs build | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Build GTFS GraphQL API documentation | |
run: | | |
npm install -g @magidoc/[email protected] | |
magidoc generate --stacktrace | |
- name: Deploy compiled HTML to Github pages | |
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master') | |
run: | | |
git config --global user.name 'OTP Bot' | |
git config --global user.email '[email protected]' | |
# mike, the versioning plugin for mkdocs, expects there to be a local branch to push to so | |
# we are cloning one here and commit to it | |
# mike has support for specifing the origin but then it tries to rebase the _local_ gh-pages | |
# branch onto the remote which fails. that's the reason for this git hackery. | |
git remote add $REMOTE https://[email protected]/opentripplanner/docs.git | |
git fetch $REMOTE $REMOTE_BRANCH:$LOCAL_BRANCH | |
# prefix is the root folder where to deploy the HTML, we use 'en' to emulate the URL | |
# structure of readthedocs | |
if [ ${{ github.ref }} = 'refs/heads/master' ]; | |
then | |
mike deploy --branch $LOCAL_BRANCH --deploy-prefix en --title=$MASTER_BRANCH_VERSION --update-aliases v$MASTER_BRANCH_VERSION latest | |
else | |
mike deploy --branch $LOCAL_BRANCH --deploy-prefix en dev-2.x | |
fi | |
# commit and push the GraphQL documentation if the schema file is newer than the | |
# compiled output. it's necessary to have this check because the diffs of the magidoc tool | |
# this are quite large and unnecessarily increase the size of the docs repo even when the | |
# schema hasn't changed. | |
# example commit: https://github.com/opentripplanner/docs/commit/45e6ddf8e4a4 | |
SCHEMA_FILE_MODIFIED=`git log -n 1 --pretty=format:%ct src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls` | |
echo "schema modified at ${SCHEMA_FILE_MODIFIED}" | |
git checkout $LOCAL_BRANCH | |
DOCS_MODIFIED=`git log -n 1 --pretty=format:%ct api/dev-2.x/graphql-gtfs/introduction.html` | |
echo "docs modified at ${DOCS_MODIFIED}" | |
if [ "${SCHEMA_FILE_MODIFIED}" -gt "${DOCS_MODIFIED}" ]; then | |
echo "schema.graphqls has been modified, committing updated documentation" | |
mkdir -p api | |
rsync -r --delete target/magidoc/api/ api/dev-2.x/ | |
git add api | |
git commit -am "Add Magidoc GraphQL documentation" | |
else | |
echo "schema.graphqls has not been modified, not committing documentation" | |
fi | |
git push $REMOTE $LOCAL_BRANCH:$REMOTE_BRANCH | |
graphql-code-generation: | |
if: github.repository_owner == 'opentripplanner' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- name: Run code generator | |
working-directory: src/main/java/org/opentripplanner/apis/gtfs/generated | |
run: | | |
yarn install | |
yarn generate | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: maven | |
- name: Compile Java code | |
run: mvn --batch-mode compile -DskipTests -P prettierSkip | |
container-image: | |
if: github.repository_owner == 'opentripplanner' && github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master') | |
runs-on: ubuntu-latest | |
needs: | |
- build-linux | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: maven | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Build container image with Jib, push to Dockerhub | |
env: | |
CONTAINER_REPO: docker.io/opentripplanner/opentripplanner | |
CONTAINER_REGISTRY_USER: otpbot | |
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
run: | | |
# we give the container two tags | |
# - "latest" | |
# - a string like "2.3_2022-12-12T21-38" | |
version_with_snapshot=`mvn -q help:evaluate -Dexpression=project.version -q -DforceStdout` | |
version=${version_with_snapshot/-SNAPSHOT/} | |
image_version=${version} | |
## if the Maven version contains SNAPSHOT, then add date to tag | |
if [[ $version_with_snapshot == *"SNAPSHOT"* ]]; then | |
image_date=`date +%Y-%m-%dT%H-%M` | |
image_version="${version}_${image_date}" | |
echo "Maven version ${version_with_snapshot} contains SNAPSHOT, adding date to container image tag" | |
fi | |
mvn --batch-mode -P prettierSkip compile com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_version |