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

Build with GHA #409

Merged
merged 13 commits into from
Oct 18, 2023
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: build

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

jobs:
build:
runs-on: ubuntu-latest

permissions: # required by aws-actions/configure-aws-credentials
id-token: write
contents: read

steps:
# Seed the build number with last number from TeamCity.
# This env var is used by the JS, and SBT builds, and guardian/actions-riff-raff.
# Set the value early, rather than `buildNumberOffset` in guardian/actions-riff-raff, to ensure each usage has the same number.
# For some reason, it's not possible to mutate GITHUB_RUN_NUMBER, so set BUILD_NUMBER instead.
- name: Set BUILD_NUMBER environment variable
run: |
LAST_TEAMCITY_BUILD=1603
echo "BUILD_NUMBER=$(( $GITHUB_RUN_NUMBER + $LAST_TEAMCITY_BUILD ))" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
distribution: "corretto"
java-version: "8"
cache: "sbt"

- name: AWS Auth
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }}
aws-region: eu-west-1

- name: Install Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Install dependencies
Georges-GNM marked this conversation as resolved.
Show resolved Hide resolved
run: yarn install --frozen-lockfile

twrichards marked this conversation as resolved.
Show resolved Hide resolved
- name: Yarn build
Georges-GNM marked this conversation as resolved.
Show resolved Hide resolved
run: yarn build

- name: Build, test and package the scala app
run: |
sbt clean compile test Debian/packageBin

- name: Build and package the notification Lambda
run: |
sbt "project notification" clean compile Universal/packageBin

- uses: guardian/actions-riff-raff@v2
with:
projectName: Editorial Tools::Workflow::Workflow Frontend
buildNumber: ${{ env.BUILD_NUMBER }}
configPath: conf/riff-raff.yaml
contentDirectories: |
workflow-frontend:
- target/workflow-frontend_0.1_all.deb
workflow-frontend-fluentbit:
- fluentbit/parsers.conf
- fluentbit/td-agent-bit.conf
Comment on lines +69 to +71
Copy link
Contributor

Choose a reason for hiding this comment

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

not for this PR, but looking forward to when we move to devx-logs (https://trello.com/c/P8JrJLHR/1345-use-devx-logs-for-workflow-frontend)

workflow-notification:
- notification/target/universal/workflow-notification.zip
1 change: 0 additions & 1 deletion app/views/healthcheck.scala.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<h1>Healthcheck OK</h1>
<h2>build-commit-id: @build.BuildInfo.gitCommitId</h2>
<h2>build-number: @build.BuildInfo.buildNumber</h2>
1 change: 0 additions & 1 deletion app/views/layout.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ <h1 class="top-toolbar__page-title">
@content

<!-- build-commit-id: @build.BuildInfo.gitCommitId -->
<!-- build-number: @build.BuildInfo.buildNumber -->

</body>
</html>
30 changes: 7 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import play.sbt.PlayImport.PlayKeys._
import Dependencies._
import com.gu.riffraff.artifact.BuildInfo
import sbtbuildinfo.BuildInfo
import scala.sys.env

Test / parallelExecution := false

val scalaVersionNumber = "2.12.15"

val buildInfo = Seq(
buildInfoPackage := "build",
buildInfoKeys ++= {
val buildInfo = BuildInfo(baseDirectory.value)

Seq[BuildInfoKey](
"gitCommitId" -> buildInfo.revision,
"buildNumber" -> buildInfo.buildIdentifier
)
}
buildInfoKeys +=
"gitCommitId" -> env.getOrElse("GITHUB_SHA", "Unknown"),
)



val commonSettings = Seq(
scalaVersion := scalaVersionNumber,
ThisBuild / scalaVersion := scalaVersionNumber,
Expand Down Expand Up @@ -63,7 +60,7 @@ lazy val commonLib = project("common-lib")
val application = "workflow-frontend"

lazy val root = playProject(application)
.enablePlugins(RiffRaffArtifact, JDebPackaging)
.enablePlugins(JDebPackaging, BuildInfoPlugin)
.settings(
libraryDependencies
++= awsDependencies
Expand All @@ -84,19 +81,6 @@ lazy val root = playProject(application)
s"-Dpidfile.path=/var/run/${packageName.value}/play.pid"
),
debianPackageDependencies := Seq("openjdk-8-jre-headless"),
riffRaffPackageType := (Debian / packageBin).value,
riffRaffUploadArtifactBucket := Option("riffraff-artifact"),
riffRaffUploadManifestBucket := Option("riffraff-builds"),
riffRaffPackageName := s"editorial-tools:workflow:$application",
riffRaffManifestProjectName := riffRaffPackageName.value,
fileDescriptorLimit := Option("32768"),
riffRaffArtifactResources := Seq(
riffRaffPackageType.value -> s"$application/${riffRaffPackageType.value.getName}",
(notificationLambda / Universal / packageBin).value -> s"${(notificationLambda / name).value}/${(notificationLambda / Universal / packageBin).value.getName}",
baseDirectory.value / "conf" / "riff-raff.yaml" -> "riff-raff.yaml",
baseDirectory.value / "fluentbit/td-agent-bit.conf" -> "workflow-frontend-fluentbit/td-agent-bit.conf",
baseDirectory.value / "fluentbit/parsers.conf" -> "workflow-frontend-fluentbit/parsers.conf"
),
Universal / javaOptions ++= Seq(
"-Dpidfile.path=/dev/null"
),
Expand Down
4 changes: 1 addition & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releas

libraryDependencies += "org.vafer" % "jdeb" % "1.8" artifacts (Artifact("jdeb", "jar", "jar"))

addSbtPlugin("com.gu" % "sbt-riffraff-artifact" % "1.1.9")

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.11")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")

Expand Down