Skip to content

Commit

Permalink
Merge pull request #3 from guardian/tweak-github-actions-build
Browse files Browse the repository at this point in the history
Use `setup-java` support for sbt-caching
  • Loading branch information
rtyley committed Dec 28, 2022
2 parents 2a74ee2 + f98bb40 commit 6cc83a9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 39 deletions.
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' }}

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
}
}

0 comments on commit 6cc83a9

Please sign in to comment.