From 684025ce99a71c32a29486108d6ffa7c21ca26ce Mon Sep 17 00:00:00 2001 From: Teemu Kalvas Date: Mon, 16 Dec 2024 12:09:53 +0200 Subject: [PATCH] Configure Digitransit CI actions --- .github/CODEOWNERS | 9 - .github/ISSUE_TEMPLATE/bug_report.md | 27 -- .github/ISSUE_TEMPLATE/feature_request.md | 24 -- .github/ISSUE_TEMPLATE/roadmap_epic.md | 22 -- .github/pull_request_template.md | 70 ----- .github/workflows/cibuild.yml | 253 ------------------ .../workflows/close_stale_pr_and_issues.yml | 24 -- .github/workflows/debug-client.yml | 88 ------ .github/workflows/dev-pipeline.yml | 58 ++++ .github/workflows/performance-test.yml | 115 -------- .github/workflows/post-merge.yml | 83 ------ .github/workflows/prod-pipeline.yml | 32 +++ .github/workflows/prune-container-images.yml | 22 -- .github/workflows/scripts/push_prod.sh | 29 ++ 14 files changed, 119 insertions(+), 737 deletions(-) delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/roadmap_epic.md delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/cibuild.yml delete mode 100644 .github/workflows/close_stale_pr_and_issues.yml delete mode 100644 .github/workflows/debug-client.yml create mode 100644 .github/workflows/dev-pipeline.yml delete mode 100644 .github/workflows/performance-test.yml delete mode 100644 .github/workflows/post-merge.yml create mode 100644 .github/workflows/prod-pipeline.yml delete mode 100644 .github/workflows/prune-container-images.yml create mode 100755 .github/workflows/scripts/push_prod.sh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 526d966f30b..00000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,9 +0,0 @@ -# See https://help.github.com/articles/about-codeowners/ - -# Members of the following team will be notified of each pull request, -# and merging PRs requires approval by a member of this team. -* @opentripplanner/otp-review-team - -# The default team above could be overridden for changes to documentation. -# TODO: reduce acceptance requirements or expand to a larger team -docs/* @opentripplanner/otp-review-team diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 15e9e772595..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: Bug report -about: Report a bug or issue -title: '' -labels: '' -assignees: '' - ---- - -**NOTE:** this issue system is intended for reporting bugs and tracking progress in software -development. For all other usage and software development questions or discussion, please post a -question in our chat room: https://gitter.im/opentripplanner/OpenTripPlanner. - - -## Expected behavior - -## Observed behavior - -## Version of OTP used (exact commit hash or JAR name) - -## Data sets in use (links to GTFS and OSM PBF files) - -## Command line used to start OTP - -## Router config and graph build config JSON - -## Steps to reproduce the problem diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 3d316646331..00000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: Feature request -about: Suggest a feature or improvement for OTP -title: '' -labels: new feature -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** - - -**Goal / high level use-case** - - - -**Describe the solution you'd like** - - -**Describe alternatives you've considered** - - -**Additional context** - diff --git a/.github/ISSUE_TEMPLATE/roadmap_epic.md b/.github/ISSUE_TEMPLATE/roadmap_epic.md deleted file mode 100644 index 2b38ba3191f..00000000000 --- a/.github/ISSUE_TEMPLATE/roadmap_epic.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: Roadmap Epic -about: Suggest an idea for the Roadmap -title: '' -labels: Roadmap -assignees: '' - ---- - -### Describe expected behavior -- What: -- Why: -- When: - -### Linked issue(s) - - -### OTP PO Discussion meeting details -- Date: -- Link(s): - -### Extra Comments (Optional) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index a67cae22195..00000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,70 +0,0 @@ -## PR Instructions - -When creating a pull request, please follow the format below. For each section, *replace* the -guidance text with your own text, keeping the section heading. If you have nothing to say in a -particular section, you can completely delete the section including its heading to indicate that you -have taken the requested steps. None of these instructions or the guidance text (non-heading text) -should be present in the submitted PR. These sections serve as a checklist: when you have replaced -or deleted all of them, the PR is considered complete. As of 2021, most regular OTP contributors -participate in our twice-weekly conference calls. For all but the simplest and smallest PRs, -participation in these discussions is necessary to facilitate the review and merge process. Other -developers can ask questions and provide immediate feedback on technical design and code style, and -resolve any concerns about long term maintenance and comprehension of new code. - -### Summary - -Explain in one or two sentences what this PR achieves. - -### Issue - -Link to or create an [issue](https://github.com/opentripplanner/OpenTripPlanner/issues) that -describes the relevant feature or bug. You need not create an issue for small bugfixes and code -cleanups, but in that case do describe the problem clearly and completely in the "summary" section -above. In the linked issue (or summary section for smaller PRs) please describe: - -- Motivation (problem or need encountered) -- How the code works -- Technical approach and any design considerations or decisions - -Remember that the PR will be reviewed by another developer who may not be familiar with your use -cases or the code you're modifying. It generally takes much less effort for the author of a PR to -explain the background and technical details than for a reviewer to infer or deduce them. PRs may be -closed if they or their linked issues do not contain sufficient information for a reviewer to -proceed. - -Add [GitHub keywords](https://help.github.com/articles/closing-issues-using-keywords/) to this PR's -description, for example: - -Closes #45 - -### Unit tests - -Write a few words on how the new code is tested. - -- Were unit tests added/updated? -- Was any manual verification done? -- Any observations on changes to performance? -- Was the code designed so it is unit testable? -- Were any tests applied to the smallest appropriate unit? -- Do all tests - pass [the continuous integration service](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/doc/user/Developers-Guide.md#continuous-integration) - ? - -### Documentation - -- Have you added documentation in code covering design and rationale behind the code? -- Were all non-trivial public classes and methods documented with Javadoc? -- Were any new configuration options added? If so were the tables in - the [configuration documentation](Configuration.md) updated? - -### Changelog - -The [changelog file](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/doc/user/Changelog.md) -is generated from the pull-request title, make sure the title describe the feature or issue fixed. -To exclude the PR from the changelog add the label `skip changelog` to the PR. - -### Bumping the serialization version id - -If you have made changes to the way the routing graph is serialized, for example by renaming a field -in one of the edges, then you must add the label `bump serialization id` to the PR. With this label -Github Actions will increase the field `otp.serialization.version.id` in `pom.xml`. diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml deleted file mode 100644 index 0368fc5c34a..00000000000 --- a/.github/workflows/cibuild.yml +++ /dev/null @@ -1,253 +0,0 @@ -name: OTP CI Build -# On [push, pull_request] causes double-builds when creating PRs. -# But triggering on push only will miss pull requests from outside authors. -# The push event's ref is the name of the pushed branch; -# The pull_request event's branch name is the merge target branch. -on: - push: - branches: - - master - - dev-1.x - - dev-2.x - pull_request: - branches: - - master - - dev-1.x - - dev-2.x -env: - # Since version 3.9.0 of Maven it will automatically understand this environment variable. - # However, as of 2024-11 the latest versions of Ubuntu and Debian were on 3.8.8 so it will take some - # time until we can remove the $MAVEN_ARGS below. - MAVEN_ARGS: "--no-transfer-progress -Dstyle.color=always" - -jobs: - build-linux: - 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 $MAVEN_ARGS jacoco:prepare-agent test jacoco:report -P prettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm - mvn $MAVEN_ARGS package -Dmaven.test.skip -P prettierSkip - - - name: Send coverage data to codecov.io - if: github.repository_owner == 'opentripplanner' - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - verbose: true - - - name: Upload test results to Codecov - # always upload test results, even when failed - if: ${{ !cancelled() }} - uses: codecov/test-results-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: "*TEST-*.xml" - - - 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 $MAVEN_ARGS deploy --settings maven-settings.xml -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY -P prettierSkip -P deployGitHub - - 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/configure-pagefile-action@v1.4 - - name: Run tests - run: mvn $MAVEN_ARGS 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.6.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/cli@6.2.0 - 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 'bot@opentripplanner.org' - - # 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://$TOKEN@github.com/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 application/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: 22 - - name: Run code generator - working-directory: application/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 $MAVEN_ARGS 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-windows - - 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 - - MAVEN_SKIP_ARGS="-P prettierSkip -Dmaven.test.skip=true -Dmaven.source.skip=true" - - mvn $MAVEN_ARGS $MAVEN_SKIP_ARGS package com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_version diff --git a/.github/workflows/close_stale_pr_and_issues.yml b/.github/workflows/close_stale_pr_and_issues.yml deleted file mode 100644 index 98619f7e763..00000000000 --- a/.github/workflows/close_stale_pr_and_issues.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: 'Close stale issues' - -on: - schedule: - - cron: '30 7 * * *' - workflow_dispatch: - -permissions: - issues: write - -jobs: - stale: - if: github.repository_owner == 'opentripplanner' - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v6.0.1 - id: stale - with: - stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days' - days-before-stale: 90 - days-before-close: 30 - operations-per-run: 260 - exempt-issue-labels: 'Roadmap' - ascending: true diff --git a/.github/workflows/debug-client.yml b/.github/workflows/debug-client.yml deleted file mode 100644 index 3c87e1c1b5c..00000000000 --- a/.github/workflows/debug-client.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Debug client - -on: - push: - paths: - - 'client/**' - pull_request: - paths: - - 'client/**' - -# to avoid conflicts, make sure that only one workflow pushes to Github at the same time -concurrency: - group: github-push - -jobs: - debug-client: - if: github.repository_owner == 'opentripplanner' - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - # this is necessary so that the correct credentials are put into the git configuration - # when we push to dev-2.x and push the compiled output to the git repo - - uses: actions/checkout@v4 - if: github.event_name == 'push' - with: - token: ${{ secrets.CHANGELOG_TOKEN }} - fetch-depth: 0 - - # for a simple PR where we don't push, we don't need any credentials - - uses: actions/checkout@v4 - if: github.event_name == 'pull_request' - - - uses: actions/setup-node@v4 - with: - node-version: 18 - - - name: Set version - run: echo "VERSION=`date +%Y/%m/%Y-%m-%dT%H:%M`" >> $GITHUB_ENV - - - name: Build debug client - working-directory: client - run: | - npm install - npm run build -- --base https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/${VERSION}/ - npm run coverage - - - name: Deploy compiled assets to repo - if: github.event_name == 'push' && github.ref == 'refs/heads/dev-2.x' - env: - REMOTE: debug-client - LOCAL_BRANCH: local-assets - REMOTE_BRANCH: main - TOKEN: ${{ secrets.CHANGELOG_TOKEN }} - run: | - # Configure git user - git config --global user.name 'OTP Bot' - git config --global user.email 'bot@opentripplanner.org' - - # Fetch the assets repo - git remote add $REMOTE https://$TOKEN@github.com/opentripplanner/debug-client-assets.git - git fetch --depth=1 $REMOTE $REMOTE_BRANCH:$LOCAL_BRANCH - - git checkout $LOCAL_BRANCH - - - # Copy the compiled output to a versioned folder - mkdir -p $VERSION - rsync -r client/output/* ./$VERSION/ - git add $VERSION - git commit -am "Add version ${VERSION} of debug client" - - # Push to assets repo https://github.com/opentripplanner/debug-client-assets - git push $REMOTE $LOCAL_BRANCH:$REMOTE_BRANCH - - # Switch back to the OTP code - git checkout dev-2.x - git pull --rebase - - CLIENT_HTML_OUTPUT=application/src/client/index.html - mkdir -p application/src/client/ - cp client/output/index.html ${CLIENT_HTML_OUTPUT} - - # just to debug - cat ${CLIENT_HTML_OUTPUT} - - git add -f ${CLIENT_HTML_OUTPUT} - git commit -m "Upgrade debug client to version ${VERSION}" - git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:dev-2.x diff --git a/.github/workflows/dev-pipeline.yml b/.github/workflows/dev-pipeline.yml new file mode 100644 index 00000000000..85083c0e6a3 --- /dev/null +++ b/.github/workflows/dev-pipeline.yml @@ -0,0 +1,58 @@ +name: Process dev-2.x push +on: + push: + branches: + - dev-2.x +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: temurin + cache: maven + + - name: Run tests + run: | + mvn test -P prettierSkip + + container-image: + runs-on: ubuntu-latest + needs: + - test + 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/hsldevcom/opentripplanner:v2 + CONTAINER_REGISTRY_USER: ${{ secrets.DOCKER_USER }} + CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_AUTH }} + run: | + otp_version="v2" + commit_hash=`git rev-parse --short "$GITHUB_SHA"` + date_time=`date +"%Y-%m-%dT%H-%M-%S"` + docker_tag_long="$otp_version-$date_time-$commit_hash" + + mvn --batch-mode -P prettierSkip install com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=$docker_tag_long diff --git a/.github/workflows/performance-test.yml b/.github/workflows/performance-test.yml deleted file mode 100644 index 5e55e158a6f..00000000000 --- a/.github/workflows/performance-test.yml +++ /dev/null @@ -1,115 +0,0 @@ -name: Performance test - -on: - push: - branches: - - dev-2.x - -jobs: - perf-test: - if: github.repository_owner == 'opentripplanner' && !startsWith(github.event.head_commit.message ,'Bump serialization version id for') && !startsWith(github.event.head_commit.message ,'Upgrade debug client to version') - runs-on: performance-test - strategy: - fail-fast: false - matrix: - include: - - # Profiles - # - # The profile variable is used to filter out some locations when the speed test is run - # on a branch during development. - # - # - locations with the 'core' profile are always run (even when on a branch) - # - locations with the 'extended' profile are only run after merging to dev-2.x - - - location: germany # all of Germany (500k stops, 200k patterns) but no OSM - iterations: 1 - jfr-delay: "50s" - profile: core - - - location: norway - iterations: 4 - jfr-delay: "35s" - profile: core - - - location: skanetrafiken - iterations: 1 - jfr-delay: "50s" - profile: core - - # extended locations that are run only after merging to dev-2.x - - - location: hamburg # German city - iterations: 1 - jfr-delay: "50s" - profile: extended - - - location: baden-wuerttemberg # German state of Baden-Württemberg: https://en.wikipedia.org/wiki/Baden-W%C3%BCrttemberg - iterations: 1 - jfr-delay: "50s" - profile: extended - - - location: switzerland - iterations: 1 - jfr-delay: "50s" - profile: extended - - - location: washington-state - iterations: 1 - jfr-delay: "20s" - profile: extended - - steps: - - uses: actions/checkout@v4 - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - with: - fetch-depth: 0 - - - name: Set up JDK - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - uses: actions/setup-java@v4 - with: - java-version: 21 - distribution: temurin - timeout-minutes: 5 - - - name: Set up Maven - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - uses: stCarolas/setup-maven@v5 - with: - maven-version: 3.8.2 - - - name: Build jar - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - env: - MAVEN_OPTS: "-Dmaven.repo.local=/home/lenni/.m2/repository/" - run: mvn -DskipTests --batch-mode install -P prettierSkip - - - name: Build graph - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - run: | - cp otp-shaded/target/otp-shaded-*-SNAPSHOT.jar otp.jar - java -Xmx32G -jar otp.jar --build --save test/performance/${{ matrix.location }}/ - - - name: Run speed test - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - env: - PERFORMANCE_INFLUX_DB_PASSWORD: ${{ secrets.PERFORMANCE_INFLUX_DB_PASSWORD }} - SPEEDTEST_LOCATION: ${{ matrix.location }} - MAVEN_OPTS: "-Xmx50g -XX:StartFlightRecording=delay=${{ matrix.jfr-delay }},duration=30m,filename=${{ matrix.location}}-speed-test.jfr -Dmaven.repo.local=/home/lenni/.m2/repository/" - run: | - mvn --projects application exec:java -Dexec.mainClass="org.opentripplanner.transit.speed_test.SpeedTest" -Dexec.classpathScope=test -Dexec.args="--dir=test/performance/${{ matrix.location }} -p md -n ${{ matrix.iterations }} -i 3 -0" - - - name: Archive travel results file - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.location }}-travelSearch-results.csv - path: test/performance/${{ matrix.location }}/travelSearch-results-md.csv - - - name: Archive Flight Recorder instrumentation file - if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x' - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.location }}-flight-recorder - path: application/${{ matrix.location }}-speed-test.jfr diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml deleted file mode 100644 index b26198e99a6..00000000000 --- a/.github/workflows/post-merge.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Post-merge -on: - pull_request_target: - branches: - - dev-2.x - types: [closed] - -# to avoid conflicts, make sure that only one workflow pushes to Github at the same time -concurrency: - group: github-push - -jobs: - changelog-entry: - if: github.event.pull_request.merged && github.repository_owner == 'opentripplanner' && !contains(github.event.pull_request.labels.*.name, 'skip changelog') - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.CHANGELOG_TOKEN }} - - - name: Configure git user - run: | - git config --global user.name 'OTP Changelog Bot' - git config --global user.email 'changelog-bot@opentripplanner.org' - - - name: Generate changelog entry from PR information - run: | - # add a line above the one which contains AUTOMATIC_CHANGELOG_PLACEHOLDER - ITEM="${TITLE} [#${NUMBER}](${URL})" - TEMP_FILE=doc/user/Changelog.generated.md - FILE=doc/user/Changelog.md - awk "/CHANGELOG_PLACEHOLDER/{print \"- $ITEM\"}1" $FILE > $TEMP_FILE - mv $TEMP_FILE $FILE - git add $FILE - git commit -m "Add changelog entry for #${NUMBER} [ci skip]" - git pull --rebase origin dev-2.x - git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:dev-2.x - env: - # Use environment variables to prevent injection attack - TITLE: ${{ github.event.pull_request.title }} - NUMBER: ${{ github.event.pull_request.number }} - URL: ${{ github.event.pull_request.html_url }} - - serialization-version: - # if you have a dependent job that is skipped (ie. you want to bump the version but not have a changelog entry) you must add - # always() before your actual condition you want for the job - # https://github.com/actions/runner/issues/491#issuecomment-660122693 - if: always() && github.event.pull_request.merged && github.repository_owner == 'opentripplanner' && contains(github.event.pull_request.labels.*.name, 'bump serialization id') - runs-on: ubuntu-latest - needs: [changelog-entry] - steps: - - - name: Install xmllint - run: | - sudo apt-get update - sudo apt-get install -y libxml2-utils - - - name: Configure git user - run: | - git config --global user.name 'OTP Serialization Version Bot' - git config --global user.email 'serialization-version-bot@opentripplanner.org' - - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.CHANGELOG_TOKEN }} - - - name: Bump serialization version - run: | - version=`xmllint --xpath "//*[local-name()='otp.serialization.version.id']/text()" pom.xml` - bumped=$((version+1)) - sed -Ei "s/.*<\/otp\.serialization\.version\.id>/${bumped}<\/otp\.serialization\.version\.id>/" pom.xml - - git add pom.xml - git commit -m "Bump serialization version id for #${NUMBER}" - # just for safety as the Github repo is eventually consistent, therefore this push competes with the changelog entry one - git pull --rebase origin dev-2.x - git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:dev-2.x - env: - # Use environment variables to prevent injection attack - NUMBER: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/prod-pipeline.yml b/.github/workflows/prod-pipeline.yml new file mode 100644 index 00000000000..3dd0b45f757 --- /dev/null +++ b/.github/workflows/prod-pipeline.yml @@ -0,0 +1,32 @@ +name: Build v2-prod from release +on: + release: + types: + - published +jobs: + v2-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set time zone to Europe/Helsinki + uses: zcong1993/setup-timezone@master + with: + timezone: "Europe/Helsinki" + - name: Check Tag + id: check-tag + run: | + if [[ ${GITHUB_REF##*/} =~ ^202[0-9][0-1][0-9][0-3][0-9] ]]; then + echo "match=true" >> $GITHUB_OUTPUT + else + echo invalid release tag + exit 1 + fi + - name: Push latest image as v2-prod + if: steps.check-tag.outputs.match == 'true' + run: ./.github/workflows/scripts/push_prod.sh + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_AUTH: ${{ secrets.DOCKER_AUTH }} + DOCKER_BASE_TAG: v2-prod + DOCKER_DEV_TAG: v2 diff --git a/.github/workflows/prune-container-images.yml b/.github/workflows/prune-container-images.yml deleted file mode 100644 index c1653701c3b..00000000000 --- a/.github/workflows/prune-container-images.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: 'Prune container images' - -on: - schedule: - - cron: '0 12 * * 1' - workflow_dispatch: - -jobs: - container-image: - if: github.repository_owner == 'opentripplanner' - runs-on: ubuntu-latest - steps: - - name: Delete unused container images - env: - CONTAINER_REPO: opentripplanner/opentripplanner - CONTAINER_REGISTRY_USER: otpbot - CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} - run: | - # remove all snapshot container images that have not been pulled for over a year - # --keep-semver makes sure that any image with a x.y.z version scheme is unaffected by this - pip install prune-container-repo==0.0.4 - prune-container-repo -u ${CONTAINER_REGISTRY_USER} -r ${CONTAINER_REPO} --days=365 --keep-semver --activate diff --git a/.github/workflows/scripts/push_prod.sh b/.github/workflows/scripts/push_prod.sh new file mode 100755 index 00000000000..72840a143cd --- /dev/null +++ b/.github/workflows/scripts/push_prod.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e + +COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA") +ORG=hsldevcom + +function imagedeploy { + DOCKER_IMAGE=$ORG/$1 + DOCKER_TAG=${DOCKER_BASE_TAG:-prod} + DOCKER_DEV_TAG=${DOCKER_DEV_TAG:-latest} + + DOCKER_TAG_LONG=$DOCKER_TAG-$(date +"%Y-%m-%dT%H.%M.%S")-$COMMIT_HASH + DOCKER_IMAGE_TAG=$DOCKER_IMAGE:$DOCKER_TAG + DOCKER_IMAGE_TAG_LONG=$DOCKER_IMAGE:$DOCKER_TAG_LONG + DOCKER_IMAGE_DEV=$DOCKER_IMAGE:$DOCKER_DEV_TAG + + echo "processing prod release" + docker pull $DOCKER_IMAGE_DEV + docker tag $DOCKER_IMAGE_DEV $DOCKER_IMAGE_TAG + docker tag $DOCKER_IMAGE_DEV $DOCKER_IMAGE_TAG_LONG + docker push $DOCKER_IMAGE_TAG + docker push $DOCKER_IMAGE_TAG_LONG +} + +docker login -u $DOCKER_USER -p $DOCKER_AUTH + +imagedeploy "opentripplanner" + +echo Deploy complete