Skip to content

Commit

Permalink
Merge pull request #497 from dlcs/develop
Browse files Browse the repository at this point in the history
Merge develop back to main
  • Loading branch information
donaldgray authored May 16, 2023
2 parents 423bf72 + 84673e3 commit f3c7ff5
Show file tree
Hide file tree
Showing 1,257 changed files with 91,795 additions and 12,858 deletions.
49 changes: 49 additions & 0 deletions .build/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pipeline {
agent {
node {
label 'master'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '100'))
}
stages {
stage('Fetch') {
steps {
deleteDir()
checkout scm: [
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false
]
],
submoduleCfg: [],
userRemoteConfigs: scm.userRemoteConfigs
]
}
}
stage('Bounce') {
steps {
sh "curl --data '{\"text\": \"Jenkins bouncing ${REGION}/${CLUSTER}/${SERVICE}...\"}' ${SLACK_WEBHOOK_URL}"
script{
for (s in env.SERVICE.split(',')) {
bounceService(s)
}
}
sh "curl --data '{\"text\": \"${REGION}/${CLUSTER}/${SERVICE} is now stable\"}' ${SLACK_WEBHOOK_URL}"
}
}
}
}

def bounceService(String service) {
sh "aws ecs update-service --force-new-deployment --cluster ${CLUSTER} --service ${service} --region ${REGION}"
sh "aws ecs wait services-stable --cluster ${CLUSTER} --services ${service} --region ${REGION}"
}
81 changes: 81 additions & 0 deletions .build/Jenkinsfile.BuildPush
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
pipeline {
agent {
node {
label 'master'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '100'))
}
stages {
stage('Fetch') {
steps {
deleteDir()
checkout scm: [
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false
]
],
submoduleCfg: [],
userRemoteConfigs: scm.userRemoteConfigs
]
}
}
stage('Install') {
steps {
sh "apt-get update"
sh "apt install -y libunwind8 gettext apt-transport-https python3-pip"
sh "pip3 install awscli"
sh "curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel 6.0"
}
}
stage('Test') {
steps {
sh "~/.dotnet/dotnet test protagonist.sln --logger trx --filter 'Category!=Database&Category!=Manual&Category!=Integration'"
step([$class: 'MSTestPublisher', testResultsFile:"**/*.trx", failOnError: true, keepLongStdio: true])
}
}
stage('Image') {
steps {
sh "docker build -t ${DOCKER_IMAGE}:latest -f ${DOCKER_FILE} ."
}
}
stage('Tag') {
steps {
sh "docker tag ${DOCKER_IMAGE}:latest ${DOCKER_IMAGE}:`git rev-parse HEAD`"
sh "docker tag ${DOCKER_IMAGE}:latest ${DOCKER_IMAGE}:production"
}
}
stage('Push') {
steps {
sh "\$(aws ecr get-login --no-include-email --region ${REGION})"
sh "docker push ${DOCKER_IMAGE}:`git rev-parse HEAD`"
sh "docker push ${DOCKER_IMAGE}:production"
}
}
stage('Bounce') {
steps {
sh "curl --data '{\"text\": \"Jenkins bouncing ${REGION}/${CLUSTER}/${SERVICE}...\"}' ${SLACK_WEBHOOK_URL}"
script{
for (s in env.SERVICE.split(',')) {
bounceService(s)
}
}
sh "curl --data '{\"text\": \"${REGION}/${CLUSTER}/${SERVICE} is now stable\"}' ${SLACK_WEBHOOK_URL}"
}
}
}
}

def bounceService(String service) {
sh "aws ecs update-service --force-new-deployment --cluster ${CLUSTER} --service ${service} --region ${REGION}"
sh "aws ecs wait services-stable --cluster ${CLUSTER} --services ${service} --region ${REGION}"
}
21 changes: 20 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
README.md
**/.idea
**/Jenkinsfile*
docs/
**/appsettings.Development.Example.json
**/appsettings.Development.json
Utils/
**/Properties/launchSettings.json

# build results
**/[Dd]ebug/
**/[Dd]ebugPublic/
**/[Rr]elease/
**/[Rr]eleases/
**/x64/
**/x86/
**/bld/
**/[Bb]in/
**/[Oo]bj/
**/[Ll]og/
53 changes: 53 additions & 0 deletions .github/actions/docker-build-and-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docker Build & Push
description: Composite GitHub Action to build and push Docker images to the DLCS GitHub Packages repositories.

inputs:
image-name:
description: "Name of the image to push to the GHCR repository."
required: true
dockerfile:
description: "The Dockerfile to build and push."
required: true
context:
description: "The context to use when building the Dockerfile."
required: true
github-token:
description: "The GitHub token used when interacting with GCHR."
required: true

runs:
using: "composite"
steps:
- id: checkout
uses: actions/checkout@v2
- id: docker-setup-buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- id: docker-meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/dlcs/${{ inputs.image-name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,enable=true,prefix=,format=long
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- id: docker-login
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.github-token }}
- id: docker-build-push
uses: docker/build-push-action@v2
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
builder: ${{ steps.docker-setup-buildx.outputs.name }}
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
push: ${{ github.actor != 'dependabot[bot]' }}
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Basic set up for three package managers

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
142 changes: 142 additions & 0 deletions .github/workflows/run_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: DLCS Build, Test & Publish

on:
push:
branches: [ "main", "develop" ]
tags: [ "v*" ]
pull_request:
branches: [ "main", "develop" ]
paths-ignore:
- "docs/**"

jobs:
test-dotnet:
runs-on: ubuntu-latest
defaults:
run:
working-directory: src/protagonist
env:
BUILD_CONFIG: "Release"
SOLUTION: "protagonist.sln"
steps:
- id: checkout
uses: actions/checkout@v3
- id: setup-dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: "6.0.x"
- id: restore-dotnet-dependencies
run: dotnet restore $SOLUTION
- id: build-dotnet
run: dotnet build $SOLUTION --configuration $BUILD_CONFIG --no-restore
- id: test-dotnet
run: dotnet test $SOLUTION --filter 'Category!=Manual' --configuration $BUILD_CONFIG --no-restore --no-build --verbosity normal

test-compositehandler:
runs-on: ubuntu-latest
steps:
- id: checkout
uses: actions/checkout@v3
- id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- id: pre-commit
uses: pre-commit/[email protected]

build-push-orchestrator:
runs-on: ubuntu-latest
needs: test-dotnet
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
name: build and push
with:
image-name: "orchestrator"
dockerfile: "Dockerfile.Orchestrator"
context: "./src/protagonist"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-thumbs:
runs-on: ubuntu-latest
needs: test-dotnet
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "thumbs"
dockerfile: "Dockerfile.Thumbs"
context: "./src/protagonist"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-engine:
runs-on: ubuntu-latest
needs: test-dotnet
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "engine"
dockerfile: "Dockerfile.Engine"
context: "./src/protagonist"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-portal:
runs-on: ubuntu-latest
needs: test-dotnet
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "portal"
dockerfile: "Dockerfile.Portal"
context: "./src/protagonist"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-api:
runs-on: ubuntu-latest
needs: test-dotnet
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "api"
dockerfile: "Dockerfile.API"
context: "./src/protagonist"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-deletehandler:
runs-on: ubuntu-latest
needs: test-dotnet
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "deletehandler"
dockerfile: "Dockerfile.DeleteHandler"
context: "./src/protagonist"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-migrator:
runs-on: ubuntu-latest
needs: test-dotnet
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "migrator"
dockerfile: "Dockerfile.Migrator"
context: "./src/protagonist"
github-token: ${{ secrets.GITHUB_TOKEN }}

build-push-compositehandler:
runs-on: ubuntu-latest
needs: test-compositehandler
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/docker-build-and-push
with:
image-name: "composite-handler"
dockerfile: "Dockerfile.CompositeHandler"
context: "./src/composite_handler"
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,6 @@ MigrationBackup/
.idea

# Generated xml documentation files
API/API.xml
API/API.xml

.env
Loading

0 comments on commit f3c7ff5

Please sign in to comment.