From c621393d4d13b7a1e3d3716bdf68111eb63e00e3 Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 14:43:23 -0500 Subject: [PATCH 1/8] Test new workflow files --- .github/workflows/build_test.yml | 45 +++++++++++++++++++++++ .github/workflows/ci_tests.yml | 45 ++++++++++++++--------- .github/workflows/compatibility_tests.yml | 35 ------------------ 3 files changed, 72 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/build_test.yml delete mode 100644 .github/workflows/compatibility_tests.yml diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml new file mode 100644 index 0000000..5731e9e --- /dev/null +++ b/.github/workflows/build_test.yml @@ -0,0 +1,45 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: Build And Test + +on: + workflow_call: + inputs: + environment: + description: Environment to run tests against + type: string + default: CI + test_args: + description: Additional arguments to dotnet test + type: string + build_configuration: + description: Whether to build debug or release configuration of the code + type: string + default: debug + +jobs: + build_test_archive: + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + working-directory: ./src + run: dotnet restore + - name: Build + working-directory: ./src + run: dotnet build --configuration {{ inputs.build_configuration }} --no-restore + - name: Upload Sage Build + uses: actions/upload-artifact@v3 + with: + name: SageWebhost + path: Sage.Webhost/bin/{{ inputs.build_configuration }}/net8.0/ + retention-days: 7 + - name: Test + working-directory: ./src + run: dotnet test --no-build --verbosity normal {{ inputs.test_args }} diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 7458f76..aba0ed1 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -5,26 +5,35 @@ name: CI Tests on: push: - branches: [ "main" ] + branches: [ "main", "release", "ci-dev" ] pull_request: - branches: [ "main" ] + branches: [ "main", "release", "ci-dev" ] jobs: - build: + init: runs-on: ubuntu-latest - + outputs: + build_configuration: ${{ steps.set_buildconfig.outputs.build_configuration }} steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - working-directory: ./src - run: dotnet restore - - name: Build - working-directory: ./src - run: dotnet build --no-restore - - name: Test - working-directory: ./src - run: dotnet test --no-build --verbosity normal --filter TestCategory!="Compatibility" + - name: Set release configuration for release branches + id: set_buildconfig + run: | + if [[ "${{github.base_ref}}" == "release" ]]; then + echo "::set-output name=build_configuration::release" + else + echo "::set-output name=build_configuration::debug" + fi + + build_test: + uses: ./.github/workflows/build_test.yml + needs: init + with: + test_args: --filter TestCategory!="Compatibility" + build_configuration: ${{ needs.init.outputs.build_configuration }} + build_test_backward_compatibility: + uses: ./.github/workflows/build_test.yml + needs: init + with: + environment: "MC Integration" + test_args: --filter TestCategory="Compatibility" + build_configuration: ${{ needs.init.outputs.build_configuration }} \ No newline at end of file diff --git a/.github/workflows/compatibility_tests.yml b/.github/workflows/compatibility_tests.yml deleted file mode 100644 index 02e9ff2..0000000 --- a/.github/workflows/compatibility_tests.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow will build a .NET project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net - -name: Compatibility Tests - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - environment: MC Integration - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: 8.0.x - - name: Restore dependencies - working-directory: ./src - run: dotnet restore - - name: Build - working-directory: ./src - run: dotnet build --no-restore - - name: Test - working-directory: ./src - env: - MC_CLIENT_ID: ${{ secrets.MC_CLIENT_ID }} - MC_CLIENT_SECRET: ${{ secrets.MC_CLIENT_SECRET }} - MC_CLIENT_MID: ${{ secrets.MC_CLIENT_MID }} - MC_CLIENT_BASE_URI: ${{ secrets.MC_CLIENT_BASE_URI }} - run: dotnet test --no-build --verbosity normal --filter TestCategory="Compatibility" From da45f1dd86269cb3f6930ca216d4143ffc272a77 Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 14:45:23 -0500 Subject: [PATCH 2/8] Fix syntax --- .github/workflows/build_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 5731e9e..a2b255f 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -33,13 +33,13 @@ jobs: run: dotnet restore - name: Build working-directory: ./src - run: dotnet build --configuration {{ inputs.build_configuration }} --no-restore + run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore - name: Upload Sage Build uses: actions/upload-artifact@v3 with: name: SageWebhost - path: Sage.Webhost/bin/{{ inputs.build_configuration }}/net8.0/ + path: Sage.Webhost/bin/${{ inputs.build_configuration }}/net8.0/ retention-days: 7 - name: Test working-directory: ./src - run: dotnet test --no-build --verbosity normal {{ inputs.test_args }} + run: dotnet test --no-build --verbosity normal ${{ inputs.test_args }} From a33f3800afab9d1a034a50cd954e5ad60998de36 Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 14:48:17 -0500 Subject: [PATCH 3/8] Only upload one build. --- .github/workflows/build_test.yml | 7 ++++++- .github/workflows/ci_tests.yml | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index a2b255f..f3af32b 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -17,6 +17,10 @@ on: description: Whether to build debug or release configuration of the code type: string default: debug + store_artifacts: + description: Determines whether or not to upload artifacts + type: boolean + default: false jobs: build_test_archive: @@ -35,10 +39,11 @@ jobs: working-directory: ./src run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore - name: Upload Sage Build + if: ${{ inputs.store_artifacts }} uses: actions/upload-artifact@v3 with: name: SageWebhost - path: Sage.Webhost/bin/${{ inputs.build_configuration }}/net8.0/ + path: ./src/Sage.Webhost/bin/${{ inputs.build_configuration }}/net8.0/ retention-days: 7 - name: Test working-directory: ./src diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index aba0ed1..27ff0c6 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -30,6 +30,7 @@ jobs: with: test_args: --filter TestCategory!="Compatibility" build_configuration: ${{ needs.init.outputs.build_configuration }} + store_artifacts: true build_test_backward_compatibility: uses: ./.github/workflows/build_test.yml needs: init From a3a070e693fb181b493b8a12ced469209fbca157 Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 14:55:19 -0500 Subject: [PATCH 4/8] Use ref name and use capital letter for directory --- .github/workflows/ci_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 27ff0c6..078a123 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -18,10 +18,10 @@ jobs: - name: Set release configuration for release branches id: set_buildconfig run: | - if [[ "${{github.base_ref}}" == "release" ]]; then - echo "::set-output name=build_configuration::release" + if [[ "${{ github.ref_name }}" == "release" ]]; then + echo "::set-output name=build_configuration::Release" else - echo "::set-output name=build_configuration::debug" + echo "::set-output name=build_configuration::Debug" fi build_test: From b3e37efb645da7d6b0a44ad5e7e631cc7b411b0c Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 15:02:16 -0500 Subject: [PATCH 5/8] Only upload artifacts for release builds --- .github/workflows/build_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index f3af32b..3a153de 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -39,7 +39,7 @@ jobs: working-directory: ./src run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore - name: Upload Sage Build - if: ${{ inputs.store_artifacts }} + if: ${{ inputs.store_artifacts && inputs.build_configuration == 'Release' }} uses: actions/upload-artifact@v3 with: name: SageWebhost From 6f3d844aa5aa08293556912c09bbf62c8c186f51 Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 15:11:28 -0500 Subject: [PATCH 6/8] Build and upload the vscode plugin --- .github/workflows/build_test.yml | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 3a153de..a160426 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -32,19 +32,29 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x + - name: Setup NPM + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + - name: Restore NPM + run: npm install -g typescript vsce ovsx - name: Restore dependencies working-directory: ./src run: dotnet restore - name: Build working-directory: ./src run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore - - name: Upload Sage Build - if: ${{ inputs.store_artifacts && inputs.build_configuration == 'Release' }} + - name: Package VSCode Plugin + working-directory: ./src/vscode + run: vsce package + - name: Upload Sage VSCode Plugin + if: ${{ inputs.store_artifacts }} uses: actions/upload-artifact@v3 with: - name: SageWebhost - path: ./src/Sage.Webhost/bin/${{ inputs.build_configuration }}/net8.0/ - retention-days: 7 + name: VSCode-Plugin + path: ./src/vscode/*.vsix + retention-days: 3 - name: Test working-directory: ./src run: dotnet test --no-build --verbosity normal ${{ inputs.test_args }} From 13721f970ad625c3bd6c7b467d9f0c372f6d726b Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 15:13:24 -0500 Subject: [PATCH 7/8] Specify package lock location --- .github/workflows/build_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index a160426..e54e393 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -36,6 +36,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: '18' + cache-dependency-path: './src/vscode/package-lock.json' cache: 'npm' - name: Restore NPM run: npm install -g typescript vsce ovsx From fcd32a62da876066b5cf02b8341aac2f963cb173 Mon Sep 17 00:00:00 2001 From: Logan Buesching Date: Thu, 11 Jan 2024 15:35:04 -0500 Subject: [PATCH 8/8] Update build order --- src/vscode/vscode.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vscode/vscode.proj b/src/vscode/vscode.proj index 446a9e1..68b4a00 100644 --- a/src/vscode/vscode.proj +++ b/src/vscode/vscode.proj @@ -16,7 +16,7 @@ - +