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

Arctrl update #20

Merged
merged 7 commits into from
Jan 23, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: 2
updates:
# Daily updates for NuGet packages
- package-ecosystem: nuget
directory: "/"
schedule:
interval: daily
groups:
DataPLANT:
patterns:
- "ARCtrl*"
- "FSSpreadsheet*"
- "DynamicObj*"
- "ARCTokenization*"
- "ControlledVocabulary*"
- "ARCExpect*"
- "ARCValidationPackages*"
- "AVPRClient*"
- "AVPRIndex*"
Tests:
patterns:
- "xunit*"
- "Expecto*"
- "Fable.Pyxpecto*"
Fable:
patterns:
- "Fable*"
Other:
exclude-patterns:
- "ARCtrl*"
- "FSSpreadsheet*"
- "DynamicObj*"
- "ARCTokenization*"
- "ControlledVocabulary*"
- "ARCExpect*"
- "ARCValidationPackages*"
- "AVPRClient*"
- "AVPRIndex*"
- "xunit*"
- "Expecto*"
- "Fable.Pyxpecto*"

# Weekly updates for GitHub Actions
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
47 changes: 0 additions & 47 deletions .github/workflows/build-and-test.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/manage-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Manage issues

on:
issues:
types:
- opened
- reopened

jobs:
label_issues:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: "Status: Needs Triage"

add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
# You can target a project in a different organization
# to the issue
project-url: https://github.com/orgs/nfdi4plants/projects/10
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
21 changes: 21 additions & 0 deletions .github/workflows/manage-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Manage PRs

on:
pull_request:
types:
- opened
- reopened

jobs:
add-to-project:
name: Add PR to project
runs-on: ubuntu-latest
steps:
# add PR to project if it is a depdendabot PR
- uses: actions/[email protected]
if: ${{ contains(github.event.pull_request.labels.*.name, 'dependencies') }}
with:
# You can target a project in a different organization
# to the issue
project-url: https://github.com/orgs/nfdi4plants/projects/10
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
137 changes: 94 additions & 43 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,128 @@
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:

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-test-windows:

runs-on: windows-latest
# 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: Build and test
working-directory: ./
run: ./build.cmd runtests

build-and-push-image:
# only publish docker images when tests succeed
needs: [build-and-test-linux, build-and-test-windows]
- 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@v45
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:
macos: false
solution: ./arc-to-invenio.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-to-invenio
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v3.3.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.6.1
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 }}
21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS base

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

COPY ./ /opt/arc-to-invenio
WORKDIR /opt/arc-to-invenio
RUN chmod +x build.sh
RUN ./build.sh runtests
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./arc-to-invenio" -c $BUILD_CONFIGURATION -o /publish

ENV PATH="${PATH}:/opt/arc-to-invenio/src/arc-to-invenio/bin/Release/net6.0"

WORKDIR /arc
FROM base AS final
COPY --from=publish /publish .
12 changes: 11 additions & 1 deletion build/BasicTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,15 @@ let clean = BuildTask.create "Clean" [] {

let build = BuildTask.create "Build" [clean] {
solutionFile
|> DotNet.build id
|> DotNet.build (fun p ->
let msBuildParams =
{p.MSBuildParams with
DisableInternalBinLog = true
}
{
p with
MSBuildParams = msBuildParams
}
|> DotNet.Options.withCustomParams (Some "-tl")
)
}
1 change: 1 addition & 0 deletions build/TestTasks.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let runTests = BuildTask.create "RunTests" [clean; build] {
Logger = Some "console;verbosity=detailed"
Configuration = DotNet.BuildConfiguration.fromString configuration
NoBuild = true
MSBuildParams = { testParams.MSBuildParams with DisableInternalBinLog = true }
}
) testProject
)
Expand Down
2 changes: 1 addition & 1 deletion build/build.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "8.0.100",
"rollForward": "latestMinor"
}
}
Loading
Loading