From 85fecbd58b191fd3c6a61e08f7a14ce485eaf833 Mon Sep 17 00:00:00 2001 From: Alison Thomson Date: Tue, 2 Jul 2024 10:57:10 +0100 Subject: [PATCH 1/5] Add CI workflow --- .github/workflows/ci-workflow.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/workflows/ci-workflow.yml diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml new file mode 100644 index 0000000..a1d85b3 --- /dev/null +++ b/.github/workflows/ci-workflow.yml @@ -0,0 +1,9 @@ +name: Continuous Integration +on: [push] # Will make the workflow run every time you push to any branch + +jobs: + build: + name: Build and test + runs-on: ubuntu-latest # Sets the build environment a machine with the latest Ubuntu installed + steps: + - uses: actions/checkout@v4 # Adds a step to checkout the repository code \ No newline at end of file From 8500ac684c194d516480328650b3d2863ba52668 Mon Sep 17 00:00:00 2001 From: Alison Thomson Date: Tue, 2 Jul 2024 11:16:30 +0100 Subject: [PATCH 2/5] Add proper steps --- .github/workflows/ci-workflow.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index a1d85b3..b206dfa 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -6,4 +6,28 @@ jobs: name: Build and test runs-on: ubuntu-latest # Sets the build environment a machine with the latest Ubuntu installed steps: - - uses: actions/checkout@v4 # Adds a step to checkout the repository code \ No newline at end of file + - uses: actions/checkout@v4 # Adds a step to checkout the repository code + + - name: Build c-sharp + run: dotnet build + + - name: Move to dotnet folder + run: cd .\DotnetTemplate.Web\ + + - name: Install dependancies + run: npm install + + - name: Build TypeScript + run: npm run build + + - name: Run TS linter + run: npm run lint + + - name: Run TS tests + run: npm t + + - name: Move to root + run: cd .. + + - name: Run c-sharp tests + run: dotnet test \ No newline at end of file From 7cf89f5318b9f925fc159a90942ea9b594a00626 Mon Sep 17 00:00:00 2001 From: Alison Thomson Date: Tue, 2 Jul 2024 11:25:47 +0100 Subject: [PATCH 3/5] Fix actual steps --- .github/workflows/ci-workflow.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index b206dfa..76763ee 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -11,23 +11,21 @@ jobs: - name: Build c-sharp run: dotnet build - - name: Move to dotnet folder - run: cd .\DotnetTemplate.Web\ - - name: Install dependancies + working-directory: ./DotnetTemplate.Web run: npm install - name: Build TypeScript + working-directory: ./DotnetTemplate.Web run: npm run build - name: Run TS linter + working-directory: ./DotnetTemplate.Web run: npm run lint - name: Run TS tests + working-directory: ./DotnetTemplate.Web run: npm t - - name: Move to root - run: cd .. - - name: Run c-sharp tests run: dotnet test \ No newline at end of file From 655353251ad539a6c1180efa8eab0c940b7db8b7 Mon Sep 17 00:00:00 2001 From: Alison Thomson Date: Tue, 2 Jul 2024 12:02:19 +0100 Subject: [PATCH 4/5] Add Slack message --- .github/workflows/ci-workflow.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 76763ee..282a50a 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -28,4 +28,25 @@ jobs: run: npm t - name: Run c-sharp tests - run: dotnet test \ No newline at end of file + run: dotnet test + + - name: Post to slack + id: slack + uses: slackapi/slack-github-action@v1.26.0 + with: + payload: | + { + "text": "Your MR pipeline has finished! Result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK \ No newline at end of file From 49e5417aba67e5961ef05c9cb83af063cccc1c09 Mon Sep 17 00:00:00 2001 From: Alison Thomson Date: Tue, 2 Jul 2024 16:10:47 +0100 Subject: [PATCH 5/5] Add Azure pipeline --- azure-pipelines.yml | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..52c8cd3 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,52 @@ +# Here we specify what causes the pipeline to run; in this case changes to any branch +trigger: +- '*' + +# Here we specify what type of machine (agent) to run on +pool: + vmImage: 'ubuntu-latest' + +# And here we specify a list of "jobs" +jobs: + - job: buildAndTestCsharp + displayName: "Build C Sharp and Run Tests" + # Each job has a sequence of steps to run + steps: + - task: DotNetCoreCLI@2 + inputs: + command: 'build' + - task: DotNetCoreCLI@2 + inputs: + command: 'test' + - job: buildTypeScript + displayName: Build TypeScript + steps: + - task: Npm@1 + inputs: + workingDir: ./DotnetTemplate.Web + command: 'install' + - task: Npm@1 + inputs: + command: 'custom' + customCommand: 'run build' + workingDir: ./DotnetTemplate.Web + - task: Npm@1 + inputs: + command: 'custom' + customCommand: 'run lint' + workingDir: ./DotnetTemplate.Web + - task: Npm@1 + inputs: + command: 'custom' + customCommand: 't' + workingDir: ./DotnetTemplate.Web + - job: publishArtefact + displayName: Publish Artefact + steps: + - script: dotnet publish -c Release -o ./dist + displayName: Generate the executable + - task: PublishPipelineArtifact@1 + displayName: Publish the artefact + inputs: + targetPath: '$(Pipeline.Workspace)' + publishLocation: 'pipeline' \ No newline at end of file