-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from Fgruntjes/initial-build
Initial build
- Loading branch information
Showing
241 changed files
with
37,296 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"swashbuckle.aspnetcore.cli": { | ||
"version": "6.5.0", | ||
"commands": [ | ||
"swagger" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,104 @@ | ||
name: Deploy | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
branches: | ||
- "main" | ||
- "beta" | ||
- "alpha" | ||
|
||
jobs: | ||
build_images: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
dotnet-version: [ '6.0.x' ] | ||
project: [ 'App.Function.Banktransaction.Import' ] | ||
project: | ||
- name: 'App.Function.Banktransaction.Import' | ||
service: 'function-banktransaction-import' | ||
dotnet-version: '7.0' | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: crazy-max/ghaction-docker-meta@v4 | ||
id: docker_meta | ||
- uses: actions/checkout@v3 | ||
- uses: google-github-actions/auth@v0 | ||
id: google_auth | ||
with: | ||
images: ghcr.io/${{ github.repository }}/${{ matrix.project }} | ||
- uses: docker/[email protected] | ||
- uses: docker/login-action@v1 | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | ||
- uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/[email protected] | ||
registry: gcr.io | ||
username: oauth2accesstoken | ||
password: ${{ steps.google_auth.outputs.access_token }} | ||
- run: echo "slug=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV | ||
- uses: docker/setup-buildx-action@v2 | ||
- uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: '${{ matrix.project.name }}/Dockerfile' | ||
push: true | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
build-args: DOTNET_VERSION=${{ matrix.project.dotnet-version }} | ||
tags: gcr.io/${{ secrets.GOOGLE_PROJECT_ID }}/${{ matrix.project.service }}:${{env.slug}} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
#if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '${{ matrix.environment }}') | ||
needs: | ||
- build_images | ||
needs: | ||
- build | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
strategy: | ||
matrix: | ||
project: [ 'App.Function.Banktransaction.Import' ] | ||
environment: [ 'beta' ] | ||
project: | ||
- 'App.Function.Banktransaction.Import' | ||
- 'App.Function.Integration.Ynab' | ||
region: [ 'europe-central2' ] | ||
steps: | ||
- run: 'echo ${{ github.ref }}' | ||
- uses: 'actions/checkout@v3' | ||
- id: 'auth' | ||
name: 'Authenticate to Google Cloud' | ||
uses: 'google-github-actions/auth@v0' | ||
with: | ||
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | ||
- id: 'deploy' | ||
uses: 'google-github-actions/deploy-cloudrun@v0' | ||
with: | ||
metadata: '${{ matrix.project }}' | ||
env_vars: 'DEPLOY_ENV=${{ matrix.environment }}' | ||
- uses: actions/checkout@v3 | ||
- uses: google-github-actions/auth@v0 | ||
with: | ||
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | ||
# Deploy function | ||
- run: echo "slug=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV | ||
- uses: actions/github-script@v6 | ||
id: environment | ||
with: | ||
script: | | ||
if (context.ref.includes('beta')) { | ||
return 'Staging'; | ||
} | ||
return 'Production'; | ||
result-encoding: string | ||
- run: echo "environment_lowercase=$(echo ${{ steps.environment.outputs.result }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | ||
- uses: mshick/fast-envsubst@v1 | ||
env: | ||
SERVICE: ${{ matrix.project }} | ||
DEPLOY_ENV: ${{ env.environment_lowercase }} | ||
DOTNET_ENVIRONMENT: ${{ steps.environment.outputs.result }} | ||
IMAGE: gcr.io/${{ secrets.GOOGLE_PROJECT_ID }}/${{ matrix.project }}:${{env.slug}} | ||
Database__ConnectionString: ${{ secrets.DATABASE__CONNECTIONSTRING }} | ||
Database__DatabaseName: ${{ steps.environment.outputs.result }} | ||
Sentry__Dsn: ${{ secrets.SENTRY__DSN }} | ||
with: | ||
in-file: ${{ matrix.project }}/service.yaml | ||
out-file: ${{ matrix.project }}/service.deploy.yaml | ||
- run: cat ${{ matrix.project }}/service.deploy.yaml | ||
- uses: google-github-actions/deploy-cloudrun@v0 | ||
id: cloudrun | ||
with: | ||
metadata: ${{ matrix.project }}/service.deploy.yaml | ||
region: ${{ matrix.region }} | ||
# Deploy infra (terraform) | ||
- uses: hashicorp/setup-terraform@v2 | ||
- run: | | ||
test -d ${{ matrix.project }}/terraform || exit 0 | ||
cd ${{ matrix.project }}/terraform | ||
terraform init | ||
terraform plan -out plan.tf \ | ||
-var "environment=${{ env.environment_lowercase }}" \ | ||
-var "cloudrun_url=${{ steps.cloudrun.outputs.url }}" | ||
terraform apply -auto-approve plan.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,44 +6,119 @@ jobs: | |
######################################################### | ||
# Code quality and unit tests | ||
######################################################### | ||
test_quality: | ||
test_quality_dotnet: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0 | ||
- run: dotnet format --verify-no-changes | ||
|
||
|
||
test_quality_terraform: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
project: | ||
- name: 'App.Function.Banktransaction.Import' | ||
service: 'function-banktransaction-import' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: hashicorp/setup-terraform@v2 | ||
- run: | | ||
test -d ${{ matrix.project.name }}/terraform || exit 0 | ||
cd ${{ matrix.project.name }}/terraform | ||
terraform init | ||
terraform validate | ||
- uses: reviewdog/action-tflint@master | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
working_directory: ${{ matrix.project.name }}/terraform | ||
reporter: github-pr-review | ||
|
||
test_quality_typescript: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
dotnet-version: [ '6.0.x' ] | ||
project: | ||
- name: 'frontend-web' | ||
nodejs-version: '18.10' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }} | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
- uses: kkak10/[email protected] | ||
id: PRNUMBER | ||
- run: | | ||
echo "file_name=FormatReport.${{ matrix.dotnet-version }}.${{steps.PRNUMBER.outputs.pr}}.${{github.run_number}}.json" >> $GITHUB_ENV | ||
- run: dotnet format --verify-no-changes | ||
|
||
test_integration: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.project.nodejs-version }} | ||
- uses: reviewdog/action-eslint@v1 | ||
with: | ||
reporter: github-pr-review | ||
workdir: ${{ matrix.project.name }} | ||
fail_on_error: true | ||
|
||
test_unit_typescript_ensure: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
project: | ||
- name: 'frontend-web' | ||
nodejs-version: '18.10' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: cd ${{ matrix.project.name }} && ./ensure_tests.sh | ||
|
||
test_unit_typescript: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
project: | ||
- name: 'frontend-web' | ||
nodejs-version: '18.10' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.project.nodejs-version }} | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0 | ||
- run: dotnet tool restore | ||
- run: | | ||
cd ${{ matrix.project.name }} | ||
npm ci | ||
./generate_api_types.sh | ||
- run: | | ||
cd ${{ matrix.project.name }} | ||
npm run test -- --reporters="default" --reporters="jest-md-dashboard" | ||
- uses: marocchino/sticky-pull-request-comment@v2 | ||
if: always() | ||
with: | ||
path: ${{ matrix.project.name }}/test-dashboard.md | ||
header: unit_typescript | ||
|
||
test_unit_dotnet: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
dotnet-version: [ '6.0.x' ] | ||
project: [ 'App.Function.Banktransaction.Import.Tests' ] | ||
project: | ||
- name: 'App.Function.Banktransaction.Import' | ||
- name: 'App.Function.Integration.Ynab' | ||
- name: 'App.Lib.Database' | ||
- name: 'App.Lib.Ynab' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }} | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
- uses: kkak10/[email protected] | ||
id: PRNUMBER | ||
- run: | | ||
echo "title=Test Run for PR #${{steps.PRNUMBER.outputs.pr}} (${{github.run_number}})" >> $GITHUB_ENV | ||
echo "file_name=TestReport.${{ matrix.dotnet-version }}.${{ matrix.project }}.${{steps.PRNUMBER.outputs.pr}}.${{github.run_number}}.md" >> $GITHUB_ENV | ||
- run: dotnet restore ${{ matrix.project }} | ||
- run: dotnet build --no-restore ${{ matrix.project }} | ||
- run: dotnet test --no-restore --no-build --logger "liquid.md;LogFileName=${{github.workspace}}/${{env.file_name}};Title=${{env.title}};" ${{ matrix.project }} | ||
- uses: marocchino/sticky-pull-request-comment@v2 | ||
if: ${{always()}} | ||
with: | ||
path: ${{github.workspace}}/${{env.file_name}} | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0 | ||
- run: | | ||
echo "title=Test Run for PR #${{github.event.number}} Run #${{github.run_number}}" >> $GITHUB_ENV | ||
echo "file_name=TestReport.${{ matrix.project.name }}.${{github.sha}}.md" >> $GITHUB_ENV | ||
- run: dotnet restore ${{ matrix.project.name }}.Tests | ||
- run: dotnet build --no-restore ${{ matrix.project.name }}.Tests | ||
- run: docker-compose -f App.Lib.Tests/docker-compose.yaml up -d | ||
- run: dotnet test --no-restore --no-build --logger "liquid.md;LogFileName=${{github.workspace}}/${{env.file_name}};Title=${{env.title}};" ${{ matrix.project.name }}.Tests | ||
- uses: marocchino/sticky-pull-request-comment@v2 | ||
if: always() | ||
with: | ||
path: ${{github.workspace}}/${{env.file_name}} | ||
header: unit_dotnet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,8 @@ bin/ | |
obj/ | ||
/packages/ | ||
riderModule.iml | ||
terraform.tfstate | ||
.terraform/ | ||
/_ReSharper.Caches/ | ||
/.idea | ||
*/swagger.json |
18 changes: 6 additions & 12 deletions
18
App.Function.Banktransaction.Import.Tests/App.Function.Banktransaction.Import.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.7.0" /> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2" /> | ||
<PackageReference Include="LiquidTestReports.Markdown" Version="1.0.9" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<ProjectReference Include="..\App.Function.Banktransaction.Import\App.Function.Banktransaction.Import.csproj" /> | ||
<ProjectReference Include="..\App.Lib.Tests\App.Lib.Tests.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\App.Function.Banktransaction.Import\App.Function.Banktransaction.Import.csproj" /> | ||
<ProjectReference Include="..\App.TestsLib\App.TestsLib.csproj" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.