Skip to content

Commit

Permalink
Remove building from running time (#155)
Browse files Browse the repository at this point in the history
Part of #4.

Thanks to this, the users don't need to wait for the project to build with Gradle,
which took around 1-2 minutes. Now it takes a few seconds to build the Docker image,
and under 1 second to run the action itself.
  • Loading branch information
krzema12 authored Nov 28, 2023
1 parent fde861a commit c1af344
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 8 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build.main.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,36 @@ workflow(
) {
uses(action = CheckoutV4())
uses(action = GradleBuildActionV2(arguments = "build"))

run(
name = "Check if the produced files are committed correctly",
command = """
set -euxo pipefail
unzip_jar() {
for jar in dist/github-actions-typing/lib/*.jar; do
echo "Extracting ${'$'}jar..."
filename=${'$'}(basename -- "${'$'}jar")
filename="${'$'}{filename%.*}"
targetDir="${'$'}1/${'$'}filename"
echo "Target directory: ${'$'}targetDir"
mkdir -p "${'$'}targetDir"
unzip -qq "${'$'}jar" -d "${'$'}targetDir"
done
}
unzip_jar "dist-unzipped-before"
rm -rf dist
unzip -qq build/distributions/github-actions-typing.zip -d dist
unzip_jar "dist-unzipped-after"
git diff --no-index --exit-code dist-unzipped-before dist-unzipped-after
""".trimIndent()
)
}

job(
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,33 @@ jobs:
uses: 'gradle/gradle-build-action@v2'
with:
arguments: 'build'
- id: 'step-2'
name: 'Check if the produced files are committed correctly'
run: |-
set -euxo pipefail
unzip_jar() {
for jar in dist/github-actions-typing/lib/*.jar; do
echo "Extracting $jar..."
filename=$(basename -- "$jar")
filename="${filename%.*}"
targetDir="$1/$filename"
echo "Target directory: $targetDir"
mkdir -p "$targetDir"
unzip -qq "$jar" -d "$targetDir"
done
}
unzip_jar "dist-unzipped-before"
rm -rf dist
unzip -qq build/distributions/github-actions-typing.zip -d dist
unzip_jar "dist-unzipped-after"
git diff --no-index --exit-code dist-unzipped-before dist-unzipped-after
validate-types:
runs-on: 'ubuntu-latest'
needs:
Expand Down
9 changes: 1 addition & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
FROM gradle:8.4.0-jdk17 AS build
COPY --chown=gradle:gradle . /src
WORKDIR /src
RUN gradle build --no-daemon
RUN rm -rf dist
RUN unzip build/distributions/github-actions-typing.zip -d dist

FROM eclipse-temurin:21.0.1_12-jre
RUN mkdir /app
COPY --from=build /src/dist/github-actions-typing/lib/*.jar /app/
COPY dist/github-actions-typing/lib/*.jar /app/
WORKDIR /app

ENTRYPOINT ["java", "-cp", "/app/*", "it.krzeminski.githubactionstyping.MainKt"]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c1af344

Please sign in to comment.