Skip to content

Commit

Permalink
Import server component from internal repository (#527)
Browse files Browse the repository at this point in the history
This PR imports code for the server we use internally to open source for others to use.
  • Loading branch information
mburumaxwell authored Feb 24, 2023
1 parent 06bacc7 commit 156b4e2
Show file tree
Hide file tree
Showing 81 changed files with 7,546 additions and 23 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "7.0.3",
"commands": [
"dotnet-ef"
]
}
}
}
27 changes: 24 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,33 @@
**/Gemfile.lock
!updater/Gemfile.lock
!updater/spec/fixtures/**/Gemfile.lock
**/node_modules
!**/spec/fixtures/*
git.store
.DS_Store
*.pyc
.dockerignore
Dockerfile*
*.md
CODEOWNERS

**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ updates:
time: "04:00"
open-pull-requests-limit: 10

- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
time: "02:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: "Microsoft.*"
update-types: ["version-update:semver-patch"]
- dependency-name: "System.*"
update-types: ["version-update:semver-patch"]
- dependency-name: "Azure.*"
update-types: ["version-update:semver-patch"]
- dependency-name: "Moq"
update-types: ["version-update:semver-patch"]

- package-ecosystem: "npm" # See documentation for possible values
directory: "/extension" # Location of package manifests
schedule:
Expand All @@ -39,3 +55,9 @@ updates:
update-types: ["version-update:semver-patch"]
- dependency-name: "@types/node"
update-types: ["version-update:semver-patch"]

registries:
tingle:
type: nuget-feed
url: 'https://pkgs.dev.azure.com/tingle/_packaging/tingle/nuget/v3/index.json'
token: '${{ secrets.TINGLE_NUGET_FEED_KEY }}'
2 changes: 2 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
matrix:
package-name:
- "dependabot-updater"
- "dependabot-server"

runs-on: ubuntu-latest

Expand All @@ -24,3 +25,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
package-name: ${{ matrix.package-name }}
min-versions-to-keep: 20
delete-only-pre-release-versions: true
8 changes: 7 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'ruby' ]
language: [ 'javascript', 'ruby', 'csharp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
Expand All @@ -54,6 +54,12 @@ jobs:
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

- name: Setup NuGet Private Feed
if: matrix.language == 'csharp'
run: |
dotnet nuget remove source tingle
dotnet nuget add source ${{ secrets.PRIVATE_FEED_URL }} --name tingle --username az --password ${{ secrets.PRIVATE_FEED_API_KEY }} --store-password-in-clear-text
dotnet restore
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
--label com.github.image.source.sha=$GITHUB_SHA \
--label com.github.image.source.branch=$GITHUB_REF \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:latest" \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:$GITVERSION_FULLSEMVER" \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:$GITVERSION_NUGETVERSIONV2" \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:$GITVERSION_MAJOR.$GITVERSION_MINOR" \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:$GITVERSION_MAJOR" \
--cache-from ghcr.io/tinglesoftware/$IMAGE_NAME:latest \
Expand All @@ -88,9 +88,9 @@ jobs:
if: github.ref == 'refs/heads/main'
run: docker push "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:latest"

- name: Push image (FullSemVer)
- name: Push image (NuGetVersionV2)
if: "!startsWith(github.ref, 'refs/pull')"
run: docker push "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITVERSION_FULLSEMVER"
run: docker push "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITVERSION_NUGETVERSIONV2"

- name: Push image (major, minor)
if: startsWith(github.ref, 'refs/tags')
Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: Server

on:
push:
branches:
- main
tags:
- '*'
paths:
- "server/**"
- ".github/workflows/server.yml"
- "!docs/**"
pull_request:
branches:
# Only trigger for PRs against `main` branch.
- main
paths:
- "server/**"
- ".github/workflows/server.yml"
- "!docs/**"

jobs:
Build:
runs-on: ubuntu-latest
env:
buildConfiguration: 'Release'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
IMAGE_NAME: 'dependabot-server'
DOCKER_BUILDKIT: 1 # Enable Docker BuildKit

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for GitVersion

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'

- name: Determine Version
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true

- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.x'
source-url: ${{ secrets.PRIVATE_FEED_URL }}
env:
NUGET_AUTH_TOKEN: ${{ secrets.PRIVATE_FEED_API_KEY }}

- name: Test
run: dotnet test -c $buildConfiguration --verbosity normal --collect "Code coverage"

- name: Publish
run: |
dotnet publish \
$GITHUB_WORKSPACE/server/Tingle.Dependabot/Tingle.Dependabot.csproj \
-c $buildConfiguration \
-o $GITHUB_WORKSPACE/drop/Tingle.Dependabot
- name: Replace tokens
uses: cschleiden/replace-tokens@v1
with:
files: '["${{ github.workspace }}/main.bicep"]'

- name: Build bicep file
uses: azure/CLI@v1
with:
inlineScript: |
cp $GITHUB_WORKSPACE/main.bicep $GITHUB_WORKSPACE/drop/main.bicep
az bicep build --file main.bicep --outfile $GITHUB_WORKSPACE/drop/main.json
- name: Pull Docker base image & warm Docker cache
run: docker pull "ghcr.io/tinglesoftware/$IMAGE_NAME:latest"
continue-on-error: true # TODO: remove after the first run

- name: Build image
run: |
docker build \
-f server/Tingle.Dependabot/Dockerfile.CI \
--label com.github.image.run.id=$GITHUB_RUN_ID \
--label com.github.image.run.number=$GITHUB_RUN_NUMBER \
--label com.github.image.job.id=$GITHUB_JOB \
--label com.github.image.source.sha=$GITHUB_SHA \
--label com.github.image.source.branch=$GITHUB_REF \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:latest" \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:$GITVERSION_NUGETVERSIONV2" \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:$GITVERSION_MAJOR.$GITVERSION_MINOR" \
-t "ghcr.io/tinglesoftware/$IMAGE_NAME:$GITVERSION_MAJOR" \
--cache-from ghcr.io/tinglesoftware/$IMAGE_NAME:latest \
--build-arg BUILDKIT_INLINE_CACHE=1 \
$GITHUB_WORKSPACE/drop/Tingle.Dependabot
- name: Log into registry
if: ${{ (github.ref == 'refs/heads/main') || (!startsWith(github.ref, 'refs/pull')) || startsWith(github.ref, 'refs/tags') }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push image (latest)
if: github.ref == 'refs/heads/main'
run: docker push "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:latest"

- name: Push image (NuGetVersionV2)
if: "!startsWith(github.ref, 'refs/pull')"
run: docker push "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITVERSION_NUGETVERSIONV2"

- name: Push image (major, minor)
if: startsWith(github.ref, 'refs/tags')
run: |
docker push "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITVERSION_MAJOR.$GITVERSION_MINOR"
docker push "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITVERSION_MAJOR"
- name: Publish Artifact
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/drop/*
name: drop

- name: Upload Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
artifacts: >
${{ github.workspace }}/drop/main.bicep,
${{ github.workspace }}/drop/main.json
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
allowUpdates: true
Loading

0 comments on commit 156b4e2

Please sign in to comment.