Skip to content

Commit ec90b6b

Browse files
authored
Merge pull request #3 from AMTSupport/C#-Compiler
C# Compiler
2 parents eed687f + 7a98bb1 commit ec90b6b

281 files changed

Lines changed: 27701 additions & 8426 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 400 additions & 1 deletion
Large diffs are not rendered by default.

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake . --no-pure-eval --accept-flake-config

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* text=auto eol=lf
2+
3+
*.cmd text eol=crlf
4+
*.bat text eol=crlf
5+
*.vbs text eol=crlf
6+
*.bas text eol=crlf

.github/workflows/build.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Compiler
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths: ["src/Compiler/**", ".github/workflows/build.yaml"]
7+
pull_request:
8+
paths: ["src/Compiler/**", ".github/workflows/build.yaml"]
9+
workflow_call:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup DotNet
20+
uses: actions/setup-dotnet@v4
21+
with:
22+
cache: true
23+
dotnet-version: 10.0.x
24+
cache-dependency-path: "src/Compiler/packages.lock.json"
25+
26+
- name: Install dependencies
27+
run: dotnet restore
28+
29+
- name: Build
30+
run: dotnet publish ./src/Compiler/Compiler.csproj -c Release -r win-x64
31+
32+
- uses: actions/upload-artifact@v4
33+
with:
34+
name: Compiler
35+
path: ./src/Compiler/bin/Release/win-x64/publish/Compiler.exe
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Powershell Compiler
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths: [ "src/**/*.ps1", ".github/workflows/compile-scripts.yaml" ]
7+
pull_request:
8+
paths: [ "src/**/*.ps1", ".github/workflows/compile-scripts.yaml" ]
9+
workflow_dispatch:
10+
11+
jobs:
12+
changes:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
compiled: ${{ steps.changes.outputs.compiled }}
16+
src: ${{ steps.changes.outputs.src }}
17+
src_deleted: ${{ steps.changes.outputs.src_deleted }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
# Checks for changes in the 'compiled' and 'src' directories
23+
# We also check for deleted files so we can cleanup the compiled directory
24+
- name: Collect Changes for Upcoming Jobs
25+
uses: dorny/paths-filter@v3.0.2
26+
id: changes
27+
with:
28+
list-files: shell
29+
filters: |
30+
compiled:
31+
- 'compiled/**'
32+
src:
33+
- 'src/**/*.(ps1|psm1)'
34+
src_deleted:
35+
- deleted: 'src/**/*.(ps1|psm1)'
36+
37+
cleanup-directory:
38+
runs-on: ubuntu-latest
39+
needs: changes
40+
if: needs.changes.outputs.src_deleted == 'true'
41+
permissions:
42+
contents: write
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
47+
- name: Delete Compiled versions of deleted files
48+
id: delete_files
49+
run: ./utils/clean-compiled.sh
50+
51+
- name: Commit Changes
52+
if: ${{ steps.delete_files.outputs.FOUND_DELETED == 'true' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
53+
uses: stefanzweifel/git-auto-commit-action@v5
54+
with:
55+
commit_message: "chore(compiled): Remove compiled versions of deleted files"
56+
57+
build:
58+
uses: ./.github/workflows/build.yaml
59+
60+
compile-scripts:
61+
runs-on: windows-latest
62+
needs: [changes, build]
63+
if: ${{ needs.changes.outputs.src == 'true' }}
64+
permissions:
65+
contents: write
66+
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
71+
- name: Download Compiler Artifact
72+
uses: dawidd6/action-download-artifact@v6
73+
with:
74+
workflow: build.yaml
75+
workflow_conclusion: success
76+
name: Compiler
77+
path: /tmp/Compiler
78+
79+
- name: Run Compiler
80+
shell: pwsh
81+
run: /tmp/Compiler/Compiler.exe --input src --output compiled --force -vvv -f
82+
83+
- name: Commit Changes
84+
if: ${{ github.event_name == 'workflow_dispatch' || (needs.changes.outputs.src == 'true' && github.event_name == 'push') }}
85+
uses: stefanzweifel/git-auto-commit-action@v5
86+
with:
87+
commit_message: "chore(compiled): Compile scripts"

.github/workflows/compiler.yaml

Lines changed: 0 additions & 104 deletions
This file was deleted.

.github/workflows/documentation.yaml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
name: Documentaion
1+
name: Generate PowerShell Docs
22

33
on:
44
push:
5-
branches: [ master ]
6-
paths: [ 'docs/**', 'src/**', 'utils/Generate-Documentation.ps1', '.github/workflows/documentation.yaml' ]
7-
pull_request:
8-
paths: [ 'docs/**', 'src/**' ]
5+
branches: [master]
6+
paths:
7+
- "docs/**"
8+
- "src/**"
9+
- "utils/Generate-Documentation.ps1"
10+
- ".github/workflows/documentation.yaml"
911

1012
jobs:
1113
update_docs:
1214
name: Update Documentation
1315
runs-on: ubuntu-latest
1416
outputs:
15-
changes: ${{ steps.changes.outputs.changes }}
17+
docs: ${{ steps.changes.outputs.docs }}
1618
permissions:
1719
contents: write
1820
pull-requests: write
@@ -23,7 +25,9 @@ jobs:
2325

2426
- name: Generate Documentation
2527
shell: pwsh
26-
run: .\utils\Generate-Documentation.ps1
28+
run: |
29+
Install-Module -Name platyPS -Scope CurrentUser
30+
.\utils\Generate-Documentation.ps1
2731
2832
- name: Check for changes
2933
id: changes
@@ -34,7 +38,7 @@ jobs:
3438
- 'docs/docs/**'
3539
3640
- name: Commit changes
37-
if: ${{ steps.changes.outputs.changes == 'true' }}
41+
if: ${{ steps.changes.outputs.docs == 'true' }}
3842
uses: stefanzweifel/git-auto-commit-action@v5
3943
with:
4044
commit_message: "chore(docs): Update documentation"
@@ -43,7 +47,7 @@ jobs:
4347
name: Deploy Documentation
4448
runs-on: ubuntu-latest
4549
needs: update_docs
46-
if : ${{ github.event_name == 'push' && needs.update_docs.outputs.changes.docs == 'true' }}
50+
if: ${{ github.event_name == 'push' && needs.update_docs.outputs.docs == 'true' }}
4751
permissions:
4852
contents: read
4953
pull-requests: read

.github/workflows/external.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: External Script Updater
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths: [ 'src/external/source/**', 'src/external/Update.ps1' ]
7+
schedule:
8+
- cron: '0 0 * * *'
9+
10+
jobs:
11+
update:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Run Update Script
19+
shell: pwsh
20+
run: ./src/external/Update.ps1
21+
22+
- name: Validate Scripts
23+
shell: pwsh
24+
run: ./src/external/Update.ps1 -Validate
25+
26+
- name: Commit Changes
27+
uses: stefanzweifel/git-auto-commit-action@v5
28+
with:
29+
commit_message: "chore(external): Update external scripts"
30+
file_pattern: "src/external/scripts/*"

.github/workflows/generate.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Generate Scripts
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- "src/automation/registry/Generate.ps1"
8+
- "src/automation/registry/definitions/**"
9+
- ".github/workflows/generate.yaml"
10+
11+
jobs:
12+
generate:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Collect Changes
18+
uses: dorny/paths-filter@v3.0.2
19+
id: changes
20+
with:
21+
list-files: shell
22+
filters: |
23+
definition:
24+
- 'src/automation/registry/definitions/**'
25+
definition_deleted:
26+
- deleted: 'src/automation/registry/definitions/**'
27+
28+
- name: Remove Deleted Definitions
29+
id: delete_files
30+
if: ${{ steps.changes.outputs.definition_deleted == 'true' }}
31+
run: |
32+
shopt -s globstar nullglob
33+
for file in src/automation/registry/definitions/**; do
34+
no_prefix=${file#src/automation/registry/definitions/}
35+
if [ ! -f "src/automation/registry/Generate.ps1" ]; then
36+
echo "Found deleted definition file ${no_prefix}, deleting."
37+
rm "$file"
38+
fi
39+
done
40+
41+
DIR="src/automation/registry"
42+
DEFINITIONS_DIR="${DIR}/definitions"
43+
GENERATED_DIR="${DIR}/generated"
44+
for file in "${GENERATED_DIR}"/*; do
45+
no_prefix=${file#"$GENERATED_DIR"/}
46+
without_extension=${no_prefix%.*}
47+
fullWithoutExtension="${DEFINITIONS_DIR}/${without_extension}"
48+
if [ ! -f "$fullWithoutExtension.json" ] && [ ! -f "$fullWithoutExtension.jsonc" ]; then
49+
echo "FOUND_DELETED=true" >> "$GITHUB_OUTPUT"
50+
echo "Found deleted generated file ${no_prefix}, deleting."
51+
rm "$file"
52+
fi
53+
done
54+
echo "Cleanup completed."
55+
56+
- name: Execute Generate Script
57+
if: ${{ steps.changes.outputs.definition == 'true' }}
58+
run: pwsh src/automation/registry/Generate.ps1
59+
60+
- name: Commit Changes
61+
if: ${{ (steps.changes.outputs.definition == 'true' || steps.delete_files.outputs.FOUND_DELETED == 'true') && github.event_name == 'push' }}
62+
uses: stefanzweifel/git-auto-commit-action@v5
63+
with:
64+
commit_message: "chore(Generated): Update generated scripts"

0 commit comments

Comments
 (0)