-
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 #20 from octodemo/develop
New user role entity
- Loading branch information
Showing
111 changed files
with
2,722 additions
and
1,310 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,24 @@ | ||
{ | ||
"name": "RazorPagesMovie Dev Container", | ||
"image": "mcr.microsoft.com/devcontainers/dotnet:6.0", | ||
"forwardPorts": [5000, 5001], | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": { | ||
"version": "latest", | ||
"autoForwardPorts": true, | ||
"moby": true | ||
} | ||
}, | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", | ||
"workspaceFolder": "/workspace", | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": [ | ||
"GitHub.copilot" | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -21,20 +21,22 @@ on: | |
required: false | ||
type: string | ||
default: 'false' | ||
|
||
env: | ||
RESOURCE_GROUP: "tsvi-rg" | ||
CONTAINER_REGISTRY: "ghcr.io/octodemo/dotnet-razor-pages-movie" | ||
|
||
jobs: | ||
staging-end2end-tests: | ||
setup-staging-environment: | ||
permissions: | ||
actions: read | ||
id-token: write # This is required for requesting the JWT | ||
contents: read # This is required for actions/checkout | ||
issues: write | ||
id-token: write | ||
contents: read | ||
|
||
|
||
runs-on: ubuntu-latest | ||
outputs: | ||
CONTAINER_APP_URL: ${{ steps.capture_outputs.outputs.CONTAINER_APP_URL }} | ||
HASH_URL: ${{ steps.generate_url.outputs.HASH_URL }} | ||
environment: STAGE | ||
steps: | ||
- name: Checkout code | ||
|
@@ -66,28 +68,70 @@ jobs: | |
- name: Capture Terraform Outputs | ||
id: capture_outputs | ||
run: | | ||
echo "CONTAINER_APP_URL=$(terraform output -raw container_app_url)" >> $GITHUB_ENV | ||
echo "CONTAINER_APP_URL=$(terraform output -raw container_app_url)" >> $GITHUB_OUTPUT | ||
working-directory: ./terraform/staging | ||
env: | ||
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | ||
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
ARM_USE_OIDC: true | ||
|
||
- name: Upload Teraaform State and files | ||
uses: actions/[email protected] | ||
with: | ||
name: terraform-state | ||
path: ./terraform/staging/ | ||
- name: Generate URL at commit hash to IaC staging files | ||
id: generate_url | ||
run: | | ||
HASH_URL="https://github.com/${{ github.repository }}/tree/${{ github.sha }}/terraform/staging" | ||
echo "HASH_URL=${HASH_URL}" >> $GITHUB_OUTPUT | ||
ui-tests: | ||
needs: setup-staging-environment | ||
permissions: | ||
actions: read | ||
contents: read | ||
|
||
strategy: | ||
matrix: | ||
browser: [chrome, firefox, edge, chromium] | ||
|
||
- name: Generate Artifact URL | ||
id: generate_artifact_url | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Setup .NET | ||
uses: actions/[email protected] | ||
with: | ||
dotnet-version: '6.0.x' | ||
|
||
- name: Run UI Automated Selenium Tests | ||
run: | | ||
ARTIFACT_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts | jq -r '.artifacts[] | select(.name=="terraform-state") | .id') | ||
echo "ARTIFACT_ID=$ARTIFACT_ID" >> $GITHUB_ENV | ||
echo "ARTIFACT_URL=https://github.com/octodemo/dotnet-razor-pages-movie/actions/runs/${{ github.run_id }}/artifacts/${ARTIFACT_ID}" >> $GITHUB_ENV | ||
dotnet test RazorPagesMovie.UITests/RazorPagesMovie.UITests.csproj --logger "console;verbosity=detailed" | ||
working-directory: tests | ||
env: | ||
BROWSER: ${{ matrix.browser }} | ||
BASE_URL: "https://${{ needs.setup-staging-environment.outputs.CONTAINER_APP_URL }}" | ||
|
||
workflow-telemetry: | ||
needs: [ui-tests] | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Workflow Telemetry - Generate heat map and performance data | ||
uses: catchpoint/[email protected] | ||
|
||
create-qa-ticket: | ||
needs: [ui-tests] | ||
permissions: | ||
actions: read | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
# Open an issue and notify QA that the staging environment is ready for testing | ||
- name: Create Issue | ||
uses: actions/[email protected] | ||
with: | ||
|
@@ -106,8 +150,7 @@ jobs: | |
- **Image Tag:** 🐳 [Docker Image](https://github.com/octodemo/dotnet-razor-pages-movie/pkgs/container/dotnet-razor-pages-movie) tag: \`${process.env.IMAGE_TAG}\` | ||
- **App Server URL:** 🔗 https://${process.env.CONTAINER_APP_URL} | ||
- **Terraform IaC files:** | ||
- **Artifact ID:** \`${process.env.ARTIFACT_ID}\` | ||
- **Artifact URL:** [📁 Download](${process.env.ARTIFACT_URL}) | ||
- **Terraform Files at Commit Hash:** 🛠️ [Commit SHA](${process.env.HASH_URL}) | ||
`; | ||
github.rest.issues.create({ | ||
|
@@ -122,20 +165,20 @@ jobs: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
IMAGE_TAG: ${{ inputs.image_tag }} | ||
CONTAINER_APP_URL: ${{ env.CONTAINER_APP_URL }} | ||
ARTIFACT_ID: ${{ env.ARTIFACT_ID }} | ||
|
||
HASH_URL: ${{ env.HASH_URL }} | ||
|
||
production: | ||
permissions: | ||
actions: read | ||
id-token: write # This is required for requesting the JWT | ||
contents: write # This is required for actions/checkout and the create-release action | ||
id-token: write | ||
contents: write | ||
|
||
runs-on: ubuntu-latest | ||
environment: | ||
name: PROD | ||
url: https://tsvi-demo-movie.salmontree-a9d9695c.eastus.azurecontainerapps.io | ||
needs: [staging-end2end-tests] | ||
needs: [create-qa-ticket] | ||
if: github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
@@ -162,20 +205,7 @@ jobs: | |
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | ||
ARM_USE_OIDC: true | ||
|
||
- name: Upload Teraaform State and files | ||
uses: actions/[email protected] | ||
with: | ||
name: terraform-state-prod | ||
path: ./terraform/production/ | ||
|
||
- name: Generate Artifact URL | ||
id: generate_artifact_url | ||
run: | | ||
ARTIFACT_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts | jq -r '.artifacts[] | select(.name=="terraform-state-prod") | .id') | ||
echo "ARTIFACT_ID=$ARTIFACT_ID" >> $GITHUB_ENV | ||
echo "ARTIFACT_URL=https://github.com/octodemo/dotnet-razor-pages-movie/actions/runs/${{ github.run_id }}/artifacts/${ARTIFACT_ID}" >> $GITHUB_ENV | ||
- name: Capture Terraform Output | ||
id: output | ||
run: echo "CONTAINER_APP_URL=$(terraform output -raw container_app_url)" >> $GITHUB_ENV | ||
|
@@ -193,8 +223,6 @@ jobs: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
IMAGE_TAG: ${{ inputs.image_tag }} | ||
CONTAINER_APP_URL: ${{ env.CONTAINER_APP_URL }} | ||
ARTIFACT_ID: ${{ env.ARTIFACT_ID }} | ||
ARTIFACT_URL: ${{ env.ARTIFACT_URL }} | ||
|
||
with: | ||
tag: ${{ inputs.image_tag }} | ||
|
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 |
---|---|---|
|
@@ -15,8 +15,6 @@ on: | |
description: 'Run the pipeline with debug deployment enabled' | ||
required: false | ||
default: 'false' | ||
|
||
# runnnig on push to main and develop branches | ||
push: | ||
branches: | ||
- main | ||
|
@@ -26,15 +24,16 @@ on: | |
- '.devcontainer/**' | ||
- '.github/ISSUE_TEMPLATE/**' | ||
- '.github/workflows/housekeeping*.yml' | ||
|
||
# running on pull requests to main and develop branches | ||
pull_request: | ||
|
||
pull_request_target: | ||
branches: | ||
- main | ||
- develop | ||
paths-ignore: | ||
- '**/README.md' | ||
- '.devcontainer/**' | ||
- '.github/ISSUE_TEMPLATE/**' | ||
- '.github/workflows/housekeeping*.yml' | ||
|
||
# defining global environment variables for all jobs | ||
env: | ||
|
@@ -48,8 +47,8 @@ env: | |
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
name: Build ${{ matrix.os }} | ||
runs-on: ${{ matrix.runner }} | ||
name: Build (${{ matrix.language }}) | ||
permissions: | ||
actions: read | ||
contents: read | ||
|
@@ -59,45 +58,68 @@ jobs: | |
|
||
strategy: | ||
matrix: | ||
# os: [ubuntu-latest, windows-latest, macos-latest] | ||
os: [ubuntu-latest] | ||
language: [csharp] | ||
include: | ||
- language: csharp | ||
build-mode: manual | ||
runner: tsvi-linux8cores | ||
- language: javascript-typescript | ||
build-mode: none | ||
runner: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
build-mode: ${{ matrix.build-mode }} | ||
|
||
- name: Setup .NET | ||
uses: actions/[email protected] | ||
with: | ||
dotnet-version: '6.0.x' | ||
|
||
- name: Cache NuGet packages | ||
if: matrix.build-mode == 'manual' | ||
uses: actions/[email protected] | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/global.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- name: Restore dependencies | ||
run: dotnet restore RazorPagesMovie.csproj | ||
if: matrix.language == 'csharp' && matrix.build-mode == 'manual' | ||
run: dotnet restore RazorPagesMovie.sln | ||
|
||
- name: Build App project | ||
run: dotnet build RazorPagesMovie.csproj --configuration Release --no-restore | ||
if: matrix.language == 'csharp' && matrix.build-mode == 'manual' | ||
run: dotnet build RazorPagesMovie.sln --configuration Release --no-restore | ||
|
||
- name: Set runtime | ||
id: set-runtime | ||
run: echo "RUNTIME=${{ matrix.os == 'ubuntu-latest' && 'linux-x64' || matrix.os == 'windows-latest' && 'win-x64' || 'osx-x64' }}" >> $GITHUB_ENV | ||
# - name: Set runtime | ||
# if: matrix.language == 'csharp' | ||
# id: set-runtime | ||
# run: echo "RUNTIME=${{ matrix.os == 'ubuntu-latest' && 'linux-x64' || matrix.os == 'windows-latest' && 'win-x64' || 'osx-x64' }}" >> $GITHUB_ENV | ||
|
||
- name: Publish | ||
run: dotnet publish RazorPagesMovie.csproj --configuration Release --output ./publish --self-contained --runtime ${{ env.RUNTIME }} | ||
if: matrix.language == 'csharp' && matrix.build-mode == 'manual' | ||
run: dotnet publish RazorPagesMovie.csproj --configuration Release --output publish --self-contained --runtime linux-x64 | ||
working-directory: src | ||
|
||
- name: Upload published app | ||
if: matrix.language == 'csharp' && matrix.build-mode == 'manual' | ||
uses: actions/[email protected] | ||
with: | ||
name: razor-linux-arm64 | ||
path: publish/ | ||
path: src/publish/ | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: "/language:${{matrix.language}}" | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
@@ -141,35 +163,41 @@ jobs: | |
id: split-test | ||
uses: scruplelesswizard/split-tests@4f1ca766cb93923ca216e02f1aefed20944e313f | ||
with: | ||
glob: RazorPagesMovie.Tests/**/*Tests.cs | ||
glob: tests/RazorPagesMovie.Tests/**/*Tests.cs | ||
split-total: ${{ env.total-runners }} | ||
split-index: ${{ matrix.index }} | ||
line-count: true | ||
|
||
- name: Restore dependencies | ||
run: dotnet restore RazorPagesMovie.Tests/RazorPagesMovie.Tests.csproj | ||
working-directory: tests | ||
|
||
- name: Convert Test File Path to Fully Qualified Name | ||
id: convert-path | ||
run: | | ||
test_suite="${{ steps.split-test.outputs.test-suite }}" | ||
fully_qualified_name=$(echo $test_suite | sed 's/\//./g' | sed 's/.cs//g') | ||
echo "test_suite=$test_suite" | ||
fully_qualified_name=$(echo $test_suite | sed 's/\//./g' | sed 's/.cs//g' | sed 's/^tests\.//g' | xargs) | ||
echo "fully_qualified_name=$fully_qualified_name" >> $GITHUB_ENV | ||
- run: 'echo "This runner will execute the following tests: ${{ steps.split-test.outputs.test-suite }}."' | ||
working-directory: tests | ||
|
||
- run: 'echo "This runner will execute the following tests: ${{ steps.split-test.outputs.test-suite }}"' | ||
- run: 'echo "Fully qualified name: ${{ env.fully_qualified_name }}"' | ||
|
||
- run: | | ||
dotnet test RazorPagesMovie.Tests/RazorPagesMovie.Tests.csproj \ | ||
--filter "FullyQualifiedName~${{ env.fully_qualified_name }}" \ | ||
--logger "console;verbosity=detailed" \ | ||
--logger "trx;LogFileName=./testresults-${{ matrix.index }}-testresults-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }}.trx" \ | ||
--results-directory ./testresults | ||
--logger "trx;LogFileName=testresults-${{ matrix.index }}-testresults-${{ matrix.os }}-${{ github.run_id }}-${{ github.run_attempt }}.trx" \ | ||
--results-directory testresults | ||
working-directory: tests | ||
- name: Upload test results | ||
if: always() | ||
uses: actions/[email protected] | ||
with: | ||
name: testresults-${{ github.run_id }}-split-${{ matrix.index }} | ||
path: ./testresults | ||
path: tests/testresults/ | ||
if-no-files-found: warn | ||
compression-level: 6 | ||
|
||
|
@@ -210,8 +238,7 @@ jobs: | |
outputs: | ||
image_tag: ${{ github.run_number }} # output the image tag to be used in the build-and-publish-docker-image job | ||
needs: [build, test] # depend on the build job to get the published app artifact | ||
if: github.ref == 'refs/heads/main' # run this job only when the branch is main branch and not on pull requests or other branches - https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context | ||
# permissions for write acces to the packages and id-token and push access to the repository to create the container registry token | ||
if: github.event_name == 'push' || (github.event_name == 'pull_request_target' && github.base_ref == 'main' && github.head_ref == 'develop') | ||
permissions: | ||
packages: write | ||
id-token: write | ||
|
Oops, something went wrong.