Skip to content

Commit

Permalink
Fix ci.yml for Gradle projects
Browse files Browse the repository at this point in the history
- Should use gradle/actions/setup-gradle action instead too
  • Loading branch information
gastaldi committed Dec 7, 2024
1 parent 47567e7 commit 2b9fbee
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK {java.version}
uses: actions/setup-java@v4
with:
java-version: {java.version}
distribution: temurin
{#if buildtool.cli == 'gradle'}
{#if buildtool.cli.contains('gradle')}
cache: gradle
{#else}
cache: maven
{/if}

{#if buildtool.cli.contains('gradle')}
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

{/if}
- name: Build
{#if buildtool.cli == 'gradle'}
uses: eskatos/gradle-command-action@v1
with:
arguments: {buildtool.cmd.build-ci}
{#else}
run: {buildtool.cli} {buildtool.cmd.build-ci}
{/if}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.quarkus.devtools.codestarts.quarkus;

import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartData.QuarkusDataKey.PROJECT_PACKAGE_NAME;
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartData.QuarkusDataKey.RESTEASY_CODESTART_RESOURCE_CLASS_NAME;
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartData.QuarkusDataKey.RESTEASY_CODESTART_RESOURCE_PATH;
import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartData.QuarkusDataKey.*;
import static io.quarkus.devtools.testing.FakeExtensionCatalog.FAKE_QUARKUS_CODESTART_CATALOG;
import static io.quarkus.devtools.testing.SnapshotTesting.assertThatMatchSnapshot;
import static io.quarkus.devtools.testing.SnapshotTesting.checkContains;
Expand Down Expand Up @@ -262,7 +260,23 @@ public void generateGradleWrapperGithubAction(TestInfo testInfo) throws Throwabl
checkGradle(projectDir);

assertThatMatchSnapshot(testInfo, projectDir, ".github/workflows/ci.yml")
.satisfies(checkContains("run: ./gradlew build"));
.satisfies(
checkContains("cache: gradle"),
checkContains("run: ./gradlew build"));
}

@Test
public void generateMavenGithubAction(TestInfo testInfo) throws Throwable {
final QuarkusCodestartProjectInput input = newInputBuilder()
.buildTool(BuildTool.MAVEN)
.addData(getGenerationTestInputData())
.addCodestarts(Collections.singletonList("tooling-github-action"))
.build();
Path projectDir = testDirPath.resolve("maven-github");
getCatalog().createProject(input).generate(projectDir);

assertThatMatchSnapshot(testInfo, projectDir, ".github/workflows/ci.yml")
.satisfies(checkContains("cache: maven"));
}

@Test
Expand All @@ -279,8 +293,9 @@ public void generateGradleNoWrapperGithubAction(TestInfo testInfo) throws Throwa
checkGradle(projectDir);

assertThatMatchSnapshot(testInfo, projectDir, ".github/workflows/ci.yml")
.satisfies(checkContains("uses: eskatos/gradle-command-action@v1"))
.satisfies(checkContains("arguments: build"));
.satisfies(
checkContains("uses: gradle/actions/setup-gradle"),
checkContains("cache: gradle"));
}

private void checkDockerfiles(Path projectDir, BuildTool buildTool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: gradle

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
uses: eskatos/gradle-command-action@v1
with:
arguments: build
run: gradle build
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: maven
cache: gradle

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: ./gradlew build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## A basic GitHub Actions workflow for your Quarkus application.

name: CI build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
cache: maven

- name: Build
run: ./mvnw verify -B

0 comments on commit 2b9fbee

Please sign in to comment.