Skip to content

Commit a24cc4a

Browse files
Initial release of AzResourceGraph module (#1)
* First version --------- Co-authored-by: Emanuel Palm <[email protected]>
1 parent 7a682a4 commit a24cc4a

29 files changed

+3632
-0
lines changed

.github/actions/build/action.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: "Build Module"
2+
3+
on:
4+
workflow_call:
5+
6+
runs:
7+
using: 'composite'
8+
steps:
9+
10+
- uses: actions/setup-dotnet@v4
11+
with:
12+
dotnet-version: '8.0.x'
13+
14+
- name: Install GitVersion
15+
uses: gittools/actions/gitversion/[email protected]
16+
with:
17+
versionSpec: '6.0.x'
18+
19+
- name: Determine Version
20+
id: gitversion
21+
uses: gittools/actions/gitversion/[email protected]
22+
with:
23+
useConfigFile: true
24+
25+
- name: Setup assets cache
26+
id: assetscache
27+
uses: actions/cache@v3
28+
with:
29+
path: output/RequiredModules
30+
key: ${{ hashFiles('RequiredModules.psd1') }}
31+
32+
- name: Download required dependencies
33+
if: steps.assetscache.outputs.cache-hit != 'true'
34+
shell: pwsh
35+
run: ./build.ps1 -ResolveDependency -Task noop
36+
37+
# Replace dot in semVer with dash, for Sampler validation in pre-release
38+
- name: Format semVer for Sampler
39+
id: formatSemVer
40+
shell: pwsh
41+
run: |
42+
$SemVer = '${{ steps.gitversion.outputs.semVer }}'
43+
# Replace last dot with dash for Sampler to accept it as pre-release, does not allow dots in pre-release name
44+
$SemVer = $SemVer -replace '^([\d\.]+\-\w+)\.(\d+)$','$1-$2'
45+
Add-Content -Path $env:GITHUB_OUTPUT -Value "formattedSemVer=$SemVer"
46+
47+
- name: Build module
48+
shell: pwsh
49+
run: ./build.ps1 -tasks pack
50+
env:
51+
ModuleVersion: ${{ steps.formatSemVer.outputs.formattedSemVer }}
52+
53+
- name: Publish build artifacts
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: ${{ env.buildArtifactName }}
57+
path: ${{ env.buildFolderName }}/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Publish test results"
2+
3+
on:
4+
workflow_call:
5+
6+
runs:
7+
using: 'composite'
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
ref: ${{ github.head_ref }}
12+
fetch-depth: 0
13+
14+
- name: Download Test Artifact Linux
15+
uses: actions/download-artifact@v4
16+
with:
17+
name: CodeCoverage-Linux
18+
path: ${{ env.buildFolderName }}/${{ env.testResultFolderName }}/CodeCoverage-Linux/
19+
20+
- name: Download Test Artifact Windows
21+
uses: actions/download-artifact@v4
22+
with:
23+
name: CodeCoverage-Windows
24+
path: ${{ env.buildFolderName }}/${{ env.testResultFolderName }}/CodeCoverage-Windows/
25+
26+
- name: Publish Linux Test Results
27+
id: linux-test-results
28+
uses: EnricoMi/publish-unit-test-result-action@v2
29+
if: always()
30+
with:
31+
nunit_files: ${{ env.buildFolderName }}/${{ env.testResultFolderName }}/CodeCoverage-Linux/NUnit*.xml
32+
check_name: Linux Test Results
33+
34+
- name: Publish Win Test Results
35+
id: win-test-results
36+
uses: EnricoMi/publish-unit-test-result-action@v2
37+
if: always()
38+
with:
39+
nunit_files: ${{ env.buildFolderName }}/${{ env.testResultFolderName }}/CodeCoverage-Windows/NUnit*.xml
40+
check_name: Win Test Results
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Test Linux"
2+
3+
on:
4+
workflow_call:
5+
6+
runs:
7+
using: 'composite'
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
ref: ${{ github.head_ref }}
12+
fetch-depth: 0
13+
14+
- name: Download Build Artifact
15+
uses: actions/download-artifact@v4
16+
with:
17+
name: ${{ env.buildArtifactName }}
18+
path: ${{ env.buildFolderName }}
19+
20+
- name: Run Tests
21+
shell: pwsh
22+
run: ./build.ps1 -tasks test
23+
24+
- name: Publish Test Artifact
25+
uses: actions/upload-artifact@v4
26+
with:
27+
path: ${{ env.buildFolderName }}/${{ env.testResultFolderName }}/
28+
name: CodeCoverage-${{ runner.os }}
29+
if: success() || failure()

.github/workflows/build.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Build, Test and Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- opened
9+
- synchronize
10+
paths-ignore:
11+
- CHANGELOG.md
12+
13+
push:
14+
branches:
15+
- main
16+
paths-ignore:
17+
- CHANGELOG.md
18+
- .github/**
19+
tags: [v*]
20+
21+
env:
22+
buildFolderName: output
23+
buildArtifactName: output
24+
testResultFolderName: testResults
25+
26+
jobs:
27+
build:
28+
name: Build
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout Code
32+
uses: actions/checkout@v4
33+
with:
34+
ref: ${{ github.head_ref }}
35+
fetch-depth: 0
36+
37+
- name: 'Build and Package Module'
38+
uses: ./.github/actions/build
39+
40+
test-linux:
41+
name: Test on Linux
42+
runs-on: ubuntu-latest
43+
needs:
44+
- build
45+
steps:
46+
- name: Checkout Code
47+
uses: actions/checkout@v4
48+
with:
49+
ref: ${{ github.head_ref }}
50+
fetch-depth: 0
51+
- name: 'Test on Linux'
52+
uses: ./.github/actions/run-tests
53+
54+
test-win:
55+
name: Test on Windows
56+
runs-on: windows-latest
57+
needs:
58+
- build
59+
steps:
60+
- name: Checkout Code
61+
uses: actions/checkout@v4
62+
with:
63+
ref: ${{ github.head_ref }}
64+
fetch-depth: 0
65+
- name: 'Test on Windows'
66+
uses: ./.github/actions/run-tests
67+
68+
code-coverage:
69+
name: Publish Code Coverage
70+
if: success() || failure()
71+
runs-on: ubuntu-latest
72+
needs:
73+
- build
74+
- test-linux
75+
- test-win
76+
steps:
77+
- name: Checkout Code
78+
uses: actions/checkout@v4
79+
with:
80+
ref: ${{ github.head_ref }}
81+
fetch-depth: 0
82+
- name: 'Publish Code Coverage'
83+
uses: ./.github/actions/code-coverage
84+
85+
release:
86+
if: success() && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
87+
runs-on: ubuntu-latest
88+
needs:
89+
- build
90+
- test-linux
91+
- code-coverage
92+
steps:
93+
- name: Checkout Code
94+
uses: actions/checkout@v4
95+
with:
96+
ref: ${{ github.head_ref }}
97+
fetch-depth: 0
98+
99+
- name: Download Build Artifact
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: ${{ env.buildArtifactName }}
103+
path: ${{ env.buildFolderName }}
104+
105+
- name: Publish Release
106+
shell: pwsh
107+
run: Import-Module ./output/RequiredModules/PowerShellForGitHub; ./build.ps1 -tasks publish
108+
env:
109+
GitHubToken: ${{ secrets.GITHUB_TOKEN }}
110+
GalleryApiToken: ${{ secrets.BICEP_PSGALLERY_KEY }}
111+
112+
- name: Send Changelog PR
113+
shell: pwsh
114+
run: Get-Module -Name PowerShellForGitHub -ListAvailable ;./build.ps1 -tasks Create_ChangeLog_GitHub_PR
115+
env:
116+
GitHubToken: ${{ secrets.GITHUB_TOKEN }}

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"[powershell]": {
3+
"files.trimTrailingWhitespace": true,
4+
"files.encoding": "utf8bom"
5+
}
6+
}

.vscode/tasks.json

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"version": "2.0.0",
3+
"_runner": "terminal",
4+
"windows": {
5+
"options": {
6+
"shell": {
7+
"executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
8+
"args": [
9+
"-NoProfile",
10+
"-ExecutionPolicy",
11+
"Bypass",
12+
"-Command"
13+
]
14+
}
15+
}
16+
},
17+
"linux": {
18+
"options": {
19+
"shell": {
20+
"executable": "/usr/bin/pwsh",
21+
"args": [
22+
"-NoProfile",
23+
"-Command"
24+
]
25+
}
26+
}
27+
},
28+
"osx": {
29+
"options": {
30+
"shell": {
31+
"executable": "/usr/local/bin/pwsh",
32+
"args": [
33+
"-NoProfile",
34+
"-Command"
35+
]
36+
}
37+
}
38+
},
39+
"tasks": [
40+
{
41+
"label": "build",
42+
"type": "shell",
43+
"command": "&${cwd}/build.ps1",
44+
"args": [],
45+
"presentation": {
46+
"echo": true,
47+
"reveal": "always",
48+
"focus": true,
49+
"panel": "new",
50+
"clear": false
51+
},
52+
"runOptions": {
53+
"runOn": "default"
54+
},
55+
"problemMatcher": [
56+
{
57+
"owner": "powershell",
58+
"fileLocation": [
59+
"absolute"
60+
],
61+
"severity": "error",
62+
"pattern": [
63+
{
64+
"regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$",
65+
"message": 1
66+
},
67+
{
68+
"regexp": "(.*)",
69+
"code": 1
70+
},
71+
{
72+
"regexp": ""
73+
},
74+
{
75+
"regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*",
76+
"file": 1,
77+
"line": 2
78+
}
79+
]
80+
}
81+
]
82+
},
83+
{
84+
"label": "test",
85+
"type": "shell",
86+
"command": "&${cwd}/build.ps1",
87+
"args": ["-AutoRestore","-Tasks","test"],
88+
"presentation": {
89+
"echo": true,
90+
"reveal": "always",
91+
"focus": true,
92+
"panel": "dedicated",
93+
"showReuseMessage": true,
94+
"clear": false
95+
},
96+
"problemMatcher": [
97+
{
98+
"owner": "powershell",
99+
"fileLocation": [
100+
"absolute"
101+
],
102+
"severity": "error",
103+
"pattern": [
104+
{
105+
"regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$",
106+
"message": 1
107+
},
108+
{
109+
"regexp": "(.*)",
110+
"code": 1
111+
},
112+
{
113+
"regexp": ""
114+
},
115+
{
116+
"regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*",
117+
"file": 1,
118+
"line": 2
119+
}
120+
]
121+
}
122+
]
123+
}
124+
]
125+
}

0 commit comments

Comments
 (0)