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

Use setup-java support for sbt-caching #3

Merged
merged 1 commit into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 22 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
name: CI

on:
workflow_dispatch:
pull_request:
# Triggering CI on default branch improves caching
# see https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache
push:
branches:
- main

env:
isPrFromForkedRepo: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != 'guardian' }}
Comment on lines 4 to -10
Copy link
Member Author

@rtyley rtyley Dec 28, 2022

Choose a reason for hiding this comment

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

It's safe to get rid of the isPrFromForkedRepo condition - as you can see in this test PR by an external account, it says "1 workflow awaiting approval" & "First-time contributors need a maintainer to approve running workflows." - GitHub has had this safeguard in place since April 2021.

image


jobs:
CI:
test:
runs-on: ubuntu-latest

# Required by aws-actions/configure-aws-credentials
Expand All @@ -19,31 +18,14 @@ jobs:
contents: read

steps:

- name: Checkout repo
uses: actions/checkout@v2

- name: Restore and save dependency cache
uses: coursier/cache-action@v6

- name: Set up Java
uses: actions/setup-java@v2
- name: Checkout
uses: actions/checkout@v3
- name: Setup JDK
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 11
distribution: adopt

- name: Test PR from forked repo
if: env.isPrFromForkedRepo == 'true'
run: sbt test

# Required by SBT riffRaffUpload
- name: Assume AWS role
if: env.isPrFromForkedRepo == 'false'
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
aws-region: eu-west-1

cache: sbt
- name: CDK
run: |
(
Expand All @@ -52,10 +34,15 @@ jobs:
npm test
npm run synth
)

- name: Upload artefacts to Riffraff
if: env.isPrFromForkedRepo == 'false'
run: >
sbt "assembly ;riffRaffUpload"


- name: Assume AWS role required for Riff-Raff upload
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
aws-region: eu-west-1
- name: Build, test and upload artifact
run: sbt -v "test ;assembly ;riffRaffUpload"
- name: Test Summary
uses: test-summary/action@v2
if: always()
with:
paths: "test-results/**/TEST-*.xml"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ target/
project/boot
logs/

test-results/

.history
.DS_Store
*~
Expand Down
7 changes: 5 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ scalacOptions ++= Seq(
"-encoding", "UTF-8"
)

val catsVersion = "2.8.0"
val catsVersion = "2.9.0"

libraryDependencies ++= Seq(
"com.amazonaws" % "aws-lambda-java-core" % "1.2.1",
Expand All @@ -26,7 +26,7 @@ libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % "2.0.0",

"com.madgag" %% "scala-collection-plus" % "0.11",
"com.google.http-client" % "google-http-client-gson" % "1.42.2",
"com.google.http-client" % "google-http-client-gson" % "1.42.3",
"com.google.apis" % "google-api-services-customsearch" % "v1-rev20210918-2.0.0",
"org.scanamo" %% "scanamo" % "1.0.0-M23",
"org.scalatest" %% "scalatest" % "3.2.14" % Test,
Expand All @@ -37,6 +37,9 @@ libraryDependencies ++= Seq(

) ++ Seq("ssm", "url-connection-client").map(artifact => "software.amazon.awssdk" % artifact % "2.17.251")

Test / testOptions +=
Tests.Argument(TestFrameworks.ScalaTest, "-u", s"test-results/scala-${scalaVersion.value}")

enablePlugins(RiffRaffArtifact, BuildInfoPlugin)

assemblyJarName := s"${name.value}.jar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class SitemapParserTest extends AnyFlatSpec with Matchers {

val output = SitemapParser.parse(stream, "https://www.independent.co.uk")

println(output)

output.size shouldBe 200
}
}