From d10406224daee1713811329a0b2d547803ab1ada Mon Sep 17 00:00:00 2001 From: lbuesching <85355760+lbuesching@users.noreply.github.com> Date: Thu, 11 Jan 2024 15:39:25 -0500 Subject: [PATCH] CI Pipeline Improvements (#27) Consolidates build & test into a single workflow file Generates a VSIX vscode package during the build --- .github/workflows/build_test.yml | 61 +++++++++++++++++++++++ .github/workflows/ci_tests.yml | 46 ++++++++++------- .github/workflows/compatibility_tests.yml | 35 ------------- src/vscode/vscode.proj | 2 +- 4 files changed, 90 insertions(+), 54 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..e54e393 --- /dev/null +++ b/.github/workflows/build_test.yml @@ -0,0 +1,61 @@ +# 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 + store_artifacts: + description: Determines whether or not to upload artifacts + type: boolean + default: false + +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: Setup NPM + 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 + - name: Restore dependencies + working-directory: ./src + run: dotnet restore + - name: Build + working-directory: ./src + run: dotnet build --configuration ${{ inputs.build_configuration }} --no-restore + - 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: VSCode-Plugin + path: ./src/vscode/*.vsix + retention-days: 3 + - 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..078a123 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -5,26 +5,36 @@ 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.ref_name }}" == "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 }} + store_artifacts: true + 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" 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 @@ - +