Skip to content

Commit

Permalink
Merge pull request #10 from nfdi4plants/integration-tests
Browse files Browse the repository at this point in the history
Add integration tests, update to .NET 8
  • Loading branch information
kMutagene authored Aug 30, 2024
2 parents 914e3ec + de2256e commit 153b674
Show file tree
Hide file tree
Showing 29 changed files with 5,233 additions and 426 deletions.
133 changes: 94 additions & 39 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,127 @@
name: Build, Test, and publish Docker image
name: "pipeline"

on:
push:
branches: ['main']
paths:
# this ensures that docker image is only published when source code or Dockerfile is changed
- 'src/**'
- 'Dockerfile'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
pull_request:
branches: ['main']

jobs:
build-and-test-linux:

jobs:
setup:
runs-on: ubuntu-latest
outputs:

# changed files output, might be relevant for other jobs
global_any_modified: ${{ steps.changed-files-yaml.outputs.global_any_modified }}
global_all_modified_files: ${{ steps.changed-files-yaml.outputs.global_all_modified_files }}

tests_all_modified_files: ${{ steps.changed-files-yaml.outputs.tests_all_modified_files }}
tests_any_modified: ${{ steps.changed-files-yaml.outputs.tests_any_modified }}

src_all_modified_files: ${{ steps.changed-files-yaml.outputs.src_all_modified_files }}
src_any_modified: ${{ steps.changed-files-yaml.outputs.src_any_modified }}

dockerfile_modified: ${{ steps.changed-files-yaml.outputs.dockerfile_any_modified }}

# trigger other jobs
trigger-build-and-test: ${{steps.set-triggers.outputs.trigger-build-and-test}}
trigger-release-docker: ${{steps.set-triggers.outputs.trigger-release-docker}}

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x.x
- name: make script executable
run: chmod u+x build.sh
- name: Build and test
working-directory: ./
run: ./build.sh runtests

build-and-push-image:
# only publish docker images when tests succeed
needs: [build-and-test-linux]
- uses: actions/checkout@v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
submodules: true
- name: Get all relevant file changes
id: changed-files-yaml
uses: tj-actions/changed-files@v42
with:
files_yaml: |
global:
- '**'
tests:
- tests/**
src:
- src/**
dockerfile:
- Dockerfile
- name: set triggers
id: set-triggers
run: |
echo "trigger-build-and-test=${{ steps.changed-files-yaml.outputs.tests_any_modified == 'true' || steps.changed-files-yaml.outputs.src_any_modified == 'true' }}" >> $GITHUB_OUTPUT
echo "trigger-release-docker=${{ github.event_name == 'push' && (steps.changed-files-yaml.outputs.tests_any_modified == 'true' || steps.changed-files-yaml.outputs.src_any_modified == 'true' || steps.changed-files-yaml.outputs.dockerfile_modified == 'true') }}" >> $GITHUB_OUTPUT
echo "$GITHUB_OUTPUT"
- name: list outputs
run: |
echo "global:"
echo "- any: ${{ steps.changed-files-yaml.outputs.global_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.global_all_modified_files }}"
echo "tests:"
echo "- any: ${{ steps.changed-files-yaml.outputs.tests_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.tests_all_modified_files }}"
echo "src:"
echo "- any: ${{ steps.changed-files-yaml.outputs.src_any_modified }}"
echo "- all: ${{ steps.changed-files-yaml.outputs.src_all_modified_files }}"
echo "dockerfile: ${{ steps.changed-files-yaml.outputs.dockerfile_modified }}"
echo "computed outputs:"
echo "trigger build-and-test: ${{steps.set-triggers.outputs.trigger-build-and-test}}"
echo "trigger docker release: ${{steps.set-triggers.outputs.trigger-release-docker}}"
- name: list triggered jobs
run: |
echo "this should trigger the following jobs:"
echo "build-and-test-projects: ${{steps.set-triggers.outputs.trigger-build-and-test}}"
echo "release-docker-image: ${{steps.set-triggers.outputs.trigger-release-docker}}"
build-and-test:
name: "Build and test"
needs: setup
# https://github.com/actions/runner/issues/1173
if: needs.setup.outputs.trigger-build-and-test == 'true'
uses: nfdi4plants/actions-workflows/.github/workflows/build-and-test-solution.yml@main
with:
solution: ./arc-export.sln
checkout-submodules: true
configuration: Release

release-docker-image:
name: "Release Docker image"
needs: [setup, build-and-test]
if: needs.setup.outputs.trigger-release-docker == 'true'
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: nfdi4plants/arc-export
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x.x
- name: make script executable
run: chmod u+x build.sh
- name: Build and test
working-directory: ./
run: ./build.sh publishbinarieslinux
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v5.5.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v5.1.0
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "ArcPrototype"]
path = tests/fixtures/ArcPrototype
url = https://git.nfdi4plants.org/muehlhaus/ArcPrototype.git
22 changes: 19 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY "src/arc-export" .
RUN dotnet restore "./arc-export.fsproj"
RUN dotnet build "./arc-export.fsproj" -c $BUILD_CONFIGURATION -o /build

COPY publish/linux-x64/arc-export .
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./arc-export.fsproj" -c $BUILD_CONFIGURATION -o /publish

#ENTRYPOINT ["/arc-export"]
FROM base AS final
COPY --from=publish /publish .

#FROM mcr.microsoft.com/dotnet/sdk:6.0
#
#
#COPY publish/linux-x64/arc-export .
#
##ENTRYPOINT ["/arc-export"]
32 changes: 10 additions & 22 deletions arc-export.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,20 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{50F222B5-E207-40FD-B817-AFBF497C83BD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{9C7BD557-3958-4BBB-8D57-3AAFA4B7CFE1}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
build.sh = build.sh
Dockerfile = Dockerfile
global.json = global.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F9989126-C2C0-450A-ACD2-D8C5C28DD28C}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ExportTests", "tests\ExportTests.fsproj", "{4A019F12-C9FC-4BBC-ADEF-C8CFE3C52022}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "build\build.fsproj", "{B29B2B22-15CE-4F48-B6C4-075FF853BFB0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{DF2FB84A-1A8C-435E-B61D-16D94BEA70B9}"
ProjectSection(SolutionItems) = preProject
Dockerfile = Dockerfile
global.json = global.json
LICENSE = LICENSE
README.md = README.md
RELEASE_NOTES.md = RELEASE_NOTES.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{100F8D7F-ECF1-4E1F-BDDF-180E10F8752F}"
ProjectSection(SolutionItems) = preProject
.github\workflows\manage-issues.yml = .github\workflows\manage-issues.yml
.github\workflows\pipeline.yml = .github\workflows\pipeline.yml
EndProjectSection
EndProject
Expand All @@ -38,32 +29,29 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "git", "git", "{1D094873-C08
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "arc-export", "src\arc-export\arc-export.fsproj", "{4C8F9483-D970-4D29-AEE2-2A71642ED6DA}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ExportTests", "tests\ExportTests.fsproj", "{5DDD8233-173C-4529-8EAB-EF778E029850}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4A019F12-C9FC-4BBC-ADEF-C8CFE3C52022}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A019F12-C9FC-4BBC-ADEF-C8CFE3C52022}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A019F12-C9FC-4BBC-ADEF-C8CFE3C52022}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A019F12-C9FC-4BBC-ADEF-C8CFE3C52022}.Release|Any CPU.Build.0 = Release|Any CPU
{B29B2B22-15CE-4F48-B6C4-075FF853BFB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B29B2B22-15CE-4F48-B6C4-075FF853BFB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B29B2B22-15CE-4F48-B6C4-075FF853BFB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B29B2B22-15CE-4F48-B6C4-075FF853BFB0}.Release|Any CPU.Build.0 = Release|Any CPU
{4C8F9483-D970-4D29-AEE2-2A71642ED6DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C8F9483-D970-4D29-AEE2-2A71642ED6DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C8F9483-D970-4D29-AEE2-2A71642ED6DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C8F9483-D970-4D29-AEE2-2A71642ED6DA}.Release|Any CPU.Build.0 = Release|Any CPU
{5DDD8233-173C-4529-8EAB-EF778E029850}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DDD8233-173C-4529-8EAB-EF778E029850}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DDD8233-173C-4529-8EAB-EF778E029850}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DDD8233-173C-4529-8EAB-EF778E029850}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4A019F12-C9FC-4BBC-ADEF-C8CFE3C52022} = {F9989126-C2C0-450A-ACD2-D8C5C28DD28C}
{B29B2B22-15CE-4F48-B6C4-075FF853BFB0} = {9C7BD557-3958-4BBB-8D57-3AAFA4B7CFE1}
{4C8F9483-D970-4D29-AEE2-2A71642ED6DA} = {50F222B5-E207-40FD-B817-AFBF497C83BD}
{5DDD8233-173C-4529-8EAB-EF778E029850} = {F9989126-C2C0-450A-ACD2-D8C5C28DD28C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B85C7FB-44A3-4872-BF02-F62CD3D8CACA}
Expand Down
20 changes: 17 additions & 3 deletions build/BasicTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ let clean = BuildTask.create "Clean" [] {
}

let build = BuildTask.create "Build" [clean] {
solutionFile
|> DotNet.build id
}
solutionFile
|> DotNet.build (fun p ->
let msBuildParams =
{p.MSBuildParams with
Properties = ([
"warnon", "3390"
])
DisableInternalBinLog = true
}
{
p with
MSBuildParams = msBuildParams

}
|> DotNet.Options.withCustomParams (Some "-tl")
)
}
27 changes: 0 additions & 27 deletions build/Build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,6 @@ initializeContext()

open BasicTasks
open TestTasks
open PackageTasks
open DocumentationTasks
open ReleaseTasks

/// Full release of nuget package, git tag, and documentation for the stable version.
let _release =
BuildTask.createEmpty
"Release"
[clean; build; runTests; pack; buildDocs; createTag; publishNuget; releaseDocs]

/// Full release of nuget package, git tag, and documentation for the prerelease version.
let _preRelease =
BuildTask.createEmpty
"PreRelease"
[setPrereleaseTag; clean; build; runTests; packPrerelease; buildDocsPrerelease; createPrereleaseTag; publishNugetPrerelease; prereleaseDocs]

/// Full release of nuget package for the prerelease version.
let _releaseNoDocs =
BuildTask.createEmpty
"ReleaseNoDocs"
[clean; build; runTests; pack; createTag; publishNuget;]

/// Full release of nuget package for the prerelease version.
let _preReleaseNoDocs =
BuildTask.createEmpty
"PreReleaseNoDocs"
[setPrereleaseTag; clean; build; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease]

[<EntryPoint>]
let main args =
Expand Down
35 changes: 0 additions & 35 deletions build/DocumentationTasks.fs

This file was deleted.

Loading

0 comments on commit 153b674

Please sign in to comment.