Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Travis CI to GitHub Actions #237

Merged
merged 13 commits into from
Oct 10, 2022
51 changes: 51 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and verify
on:
pull_request:
types: [opened, synchronize, reopened]
Copy link
Member

Choose a reason for hiding this comment

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

There are the default, so we can omit them.

Copy link
Member

Choose a reason for hiding this comment

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

I see I forgot to push this.

push:
branches: [$default-branch]
Copy link
Member

Choose a reason for hiding this comment

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

We saw in PicnicSupermarket/error-prone-support#278 that unfortunately this doesn't work.

jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- jdk: 11.0.16
sonarEnabled: true
- jdk: 17.0.4
sonarEnabled: false
steps:
- name: Check out code
uses: actions/[email protected]
with:
# Fetch entire history for SonarCloud analysis.
fetch-depth: 0
- name: Set up JDK
uses: actions/[email protected]
with:
java-version: ${{ matrix.jdk }}
distribution: temurin
cache: maven
- name: Cache SonarCloud packages
if: ${{ matrix.sonarEnabled }}
uses: actions/[email protected]
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
Copy link
Member

Choose a reason for hiding this comment

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

Nice. (In a separate PR) we might want to do something similar for Maven dependencies.

(Or are those cached by default? Below we have "Remove installed project artifacts" after all.)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, nevermind; I now see the cache parameter to actions/setup-java.

- name: Display build environment details
run: mvn --version
- name: Build the project
run: mvn -T1C install
- name: Perform SonarCloud analysis
if: ${{ matrix.sonarEnabled }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >-
mvn sonar:sonar
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=picnic-technologies
-Dsonar.projectKey=tech.picnic:oss-parent
Copy link
Member

Choose a reason for hiding this comment

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

The first two will also apply downstream; we can add them to pom.xml. The third should be inferred; let me test that 👀

Copy link
Member

Choose a reason for hiding this comment

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

Seems to work 😄

- name: Remove installed project artifacts
run: mvn build-helper:remove-project-artifact
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--batch-mode --errors --strict-checksums
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Picnic OSS Maven Parent

[![Build Status][travisci-badge]][travisci-builds]
[![GitHub Actions][github-actions-build-badge]][github-actions-build-master]
[![Maven Central][maven-central-badge]][maven-central-browse]
[![SonarCloud Quality Gate][sonarcloud-badge-quality-gate]][sonarcloud-dashboard]
[![SonarCloud Bugs][sonarcloud-badge-bugs]][sonarcloud-measure-reliability]
Expand Down Expand Up @@ -34,6 +34,8 @@ When submitting changes, please make every effort to follow existing
conventions and style in order to keep the configuration as readable as
possible.

[github-actions-build-badge]: https://github.com/PicnicSupermarket/error-prone-support/actions/workflows/build.yaml/badge.svg
[github-actions-build-master]: https://github.com/PicnicSupermarket/error-prone-support/actions/workflows/build.yaml?query=branch%3Amaster
Copy link
Member

Choose a reason for hiding this comment

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

👀 wrong project.

[maven-central-badge]: https://img.shields.io/maven-central/v/tech.picnic/oss-parent.svg
[maven-central-browse]: https://repo1.maven.org/maven2/tech/picnic/oss-parent/
[maven-central-search]: https://search.maven.org
Expand All @@ -47,5 +49,3 @@ possible.
[sonarcloud-measure-reliability]: https://sonarcloud.io/component_measures?id=tech.picnic%3Aoss-parent&metric=Reliability
[sonarcloud-measure-security]: https://sonarcloud.io/component_measures?id=tech.picnic%3Aoss-parent&metric=Security
[sonarcloud-measure-maintainability]: https://sonarcloud.io/component_measures?id=tech.picnic%3Aoss-parent&metric=Maintainability
[travisci-badge]: https://travis-ci.org/PicnicSupermarket/oss-parent.svg?branch=master
[travisci-builds]: https://travis-ci.org/PicnicSupermarket/oss-parent
20 changes: 6 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<url>https://github.com/PicnicSupermarket/oss-parent/issues</url>
</issueManagement>
<ciManagement>
<system>Travis CI</system>
<url>https://travis-ci.com/PicnicSupermarket/oss-parent</url>
<system>GitHub Actions</system>
<url>https://github.com/PicnicSupermarket/oss-parent/actions</url>
</ciManagement>
<distributionManagement>
<repository>
Expand All @@ -66,9 +66,9 @@
<!-- The test JVMs are short-running. By disabling certain
expensive JIT optimizations we actually speed up most tests. -->
-XX:TieredStopAtLevel=1
<!-- We cap memory usage. This is especially relevant on Travis CI,
but locally this should also be more than enough. -->
-Xmx512m
<!-- We cap memory usage. This is especially relevant on CI, but
Copy link
Member

Choose a reason for hiding this comment

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

This change is also based on our internal build file.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, we use a different text in error-prone-support, with the latter text seemingly of more recent vintage.

locally this should also be more than enough. -->
-Xmx1024m
<!-- This argument cannot be set through Surefire's
'systemPropertyVariables' configuration setting. Setting the file
encoding is necessary because forked unit test invocations
Expand All @@ -87,7 +87,7 @@
from showing up in the dock and capturing window focus. -->
-Djava.awt.headless=true
</argLine>
<!-- Our build system (Travis CI) provides a monotonically increasing
<!-- Our build system (GitHub Actions) provides a monotonically increasing
build number. When building locally, this number is obviously absent.
So we provide a default value. -->
Copy link
Member

Choose a reason for hiding this comment

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

I'll sync the phrasing with error-prone-support, but wonder: does this actually work still? (Something we can test separately; no need to block the PR over it.)

<build.number>LOCAL</build.number>
Expand Down Expand Up @@ -306,14 +306,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.takari</groupId>
<artifactId>maven</artifactId>
<version>0.7.7</version>
<configuration>
<maven>${version.maven}</maven>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down