-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from drache42/github-actions
GitHub actions
- Loading branch information
Showing
15 changed files
with
879 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Setup .NET | ||
description: 'Setup .NET' | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: nuget Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.nuget/packages | ||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-nuget- | ||
- name: Setup .NET 6.0 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 6.0.x | ||
- name: Setup .NET 7.0 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 7.0.x | ||
- name: Setup .NET 8.0 | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 8.0.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
PR Checklist: | ||
|
||
- [ ] Link to GUS Item [W-123456](http:///) | ||
- [ ] One of these Release Note Labels Applied to PR: | ||
- `internal` | ||
- `breaking-change` | ||
- `feature` | ||
- `fix` | ||
- `documentation` | ||
- [ ] Unit Tests | ||
- [ ] Simulation Tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
changelog: | ||
exclude: | ||
labels: | ||
- internal | ||
categories: | ||
- title: Breaking Changes | ||
labels: | ||
- breaking-change | ||
- title: New Features | ||
labels: | ||
- feature | ||
- title: Fixes | ||
labels: | ||
- fix | ||
- title: Documentation | ||
labels: | ||
- documentation | ||
- title: Other Changes | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# GitHub Workflows | ||
|
||
Here we have defined the workflows used for CI/CD for this SDK. | ||
The files here are: | ||
- dotnetworkflow.yml: This file is a template that is used by the SDK workflow. This template has the following parameters: | ||
- runs-on-config (mandatory): indicates the runner that will run the workflow. Available runners [here](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners). | ||
- dotnet-version (mandatory): indicates the dotnet version that will be installed on the runner. The available versions depends on the runners. Check it on the link above. | ||
- build-config (mandatory): indicates the configuration used to build/test the sdk. | ||
- run-tests (mandatory): indicates if the workflow will run the unit tests. | ||
- publish-package (mandatory): indicates if the workflow will publish the artifacts (packages). | ||
- sdk-workflow.yml: This is the real workflow that will run on every PR or every push on the defined branches. | ||
|
||
For any changes, you can use the following documentation ([GitHub Actions Syntax](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)) as a reference. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# This workflow will create a new release for the current SDK | ||
name: Create Release Workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
runs-on-config: | ||
required: true | ||
type: string | ||
release-version: | ||
required: true | ||
type: string | ||
is-pre-release: | ||
required: true | ||
type: boolean | ||
|
||
jobs: | ||
create-release: | ||
runs-on: ${{ inputs.runs-on-config }} | ||
name: Create a New Release | ||
steps: | ||
- name: Create Release | ||
id: create-release | ||
uses: actions/github-script@v6 | ||
env: | ||
RELEASE_VERSION: ${{ inputs.release-version }} | ||
IS_PRERELEASE: ${{ inputs.is-pre-release }} | ||
with: | ||
result-encoding: string | ||
script: | | ||
const { RELEASE_VERSION, IS_PRERELEASE } = process.env | ||
const release_version = `release/${RELEASE_VERSION}` | ||
const is_prerelease = IS_PRERELEASE === 'true' | ||
const createReleaseResponse = await github.rest.repos.createRelease({ | ||
owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. | ||
repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. | ||
tag_name: release_version, // (Required) The name of the tag. | ||
target_commitish: context.sha, // (Optional) Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch. | ||
name: release_version, // (Optional) The name of the release. | ||
// body: '', // (Optional) Text describing the contents of the tag. | ||
// draft: true, // (Optional) true to create a draft (unpublished) release, false to create a published one. | ||
prerelease: is_prerelease, // (Optional) true to identify the release as a prerelease. false to identify the release as a full release. | ||
// discussion_category_name: , // (Optional) If specified, a discussion of the specified category is created and linked to the release. The value must be a category that already exists in the repository. For more information, see "Managing categories for discussions in your repository." | ||
// make_latest: false, // (Optional) Specifies whether this release should be set as the latest release for the repository. Drafts and prereleases cannot be set as latest. Defaults to true for newly published releases. legacy specifies that the latest release should be determined based on the release creation date and higher semantic version. | ||
generate_release_notes: true // (Optional) Whether to automatically generate the name and body for this release. If name is specified, the specified name will be used; otherwise, a name will be automatically generated. If body is specified, the body will be pre-pended to the automatically generated notes. | ||
}) | ||
return createReleaseResponse.data.id | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: docs | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: nuget-package | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: pypi-package | ||
- name: Generate Bundle | ||
run: | | ||
zip -r bundle.zip ./Tableau.Migration.${{ inputs.release-version }}.nupkg docs.zip tableau_migration-pypi.zip | ||
- name: Upload Release Assets | ||
id: upload-docs | ||
uses: actions/github-script@v6 | ||
env: | ||
RELEASE_VERSION: ${{ inputs.release-version }} | ||
RELEASE_ID: ${{ steps.create-release.outputs.result }} | ||
with: | ||
script: | | ||
const fs = require('fs') | ||
const { RELEASE_VERSION, RELEASE_ID } = process.env | ||
const nuget_package = `Tableau.Migration.${RELEASE_VERSION}.nupkg` | ||
const uploadDocsResponse = await await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. | ||
repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. | ||
release_id: RELEASE_ID, // (Required) The unique identifier of the release. | ||
name: 'docs.zip', // (Required) | ||
label: 'Docs (zip)', // (Optional) | ||
data: fs.readFileSync('./docs.zip') // (Optional) The raw file data. | ||
}) | ||
const uploadNugetResponse = await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. | ||
repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. | ||
release_id: RELEASE_ID, // (Required) The unique identifier of the release. | ||
name: 'Tableau.Migration.nupkg', // (Required) | ||
label: 'Nuget Package (nupkg)', // (Optional) | ||
data: fs.readFileSync(nuget_package) // (Optional) The raw file data. | ||
}) | ||
const uploadPypiResponse = await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. | ||
repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. | ||
release_id: RELEASE_ID, // (Required) The unique identifier of the release. | ||
name: 'tableau_migration-pypi.zip', // (Required) | ||
label: 'Pypi Package (zip)', // (Optional) | ||
data: fs.readFileSync('./tableau_migration-pypi.zip') // (Optional) The raw file data. | ||
}) | ||
const uploadBundleResponse = await github.rest.repos.uploadReleaseAsset({ | ||
owner: context.repo.owner, // (Required) The account owner of the repository. The name is not case sensitive. | ||
repo: context.repo.repo, // (Required) The name of the repository without the .git extension. The name is not case sensitive. | ||
release_id: RELEASE_ID, // (Required) The unique identifier of the release. | ||
name: 'bundle.zip', // (Required) | ||
label: 'Bundle Package (zip)', // (Optional) | ||
data: fs.readFileSync('./bundle.zip') // (Optional) The raw file data. | ||
}) | ||
return { | ||
docs: uploadDocsResponse.data, | ||
nuget: uploadNugetResponse.data, | ||
pypi: uploadPypiResponse.data, | ||
bundle: uploadBundleResponse.data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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: .Net Build Workflow | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
beta-version: | ||
required: true | ||
type: string | ||
|
||
env: | ||
MIGRATIONSDK_BUILD_DOCS: 'no' | ||
VERSION_REPLACE_ARGS: '' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ${{ fromJSON(vars.BUILD_OS) }} | ||
config: ${{ fromJSON(vars.BUILD_CONFIGURATIONS) }} | ||
runs-on: ${{ matrix.os }} | ||
name: .Net Build ${{ matrix.os }}, ${{ matrix.config }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/setup-dotnet | ||
- name: Set Replaced Version Windows | ||
if: ${{ runner.os == 'Windows' && inputs.beta-version != '' }} | ||
run: echo "VERSION_REPLACE_ARGS=-p:Version='${{ inputs.beta-version }}'" | Out-File -FilePath $env:GITHUB_ENV -Append # no need for -Encoding utf8- uses: actions/checkout@v3 | ||
- name: Set Replaced Version Not Windows | ||
if: ${{ runner.os != 'Windows' && inputs.beta-version != '' }} | ||
run: echo "VERSION_REPLACE_ARGS=-p:Version='${{ inputs.beta-version }}'" >> $GITHUB_ENV | ||
- name: Net Build Library ${{ matrix.config }} Beta Version ${{ inputs.beta-version }} | ||
run: dotnet build '${{ vars.BUILD_SOLUTION }}' -c ${{ matrix.config }} ${{ env.VERSION_REPLACE_ARGS }} | ||
- name: Net Publish Library ${{ matrix.config }} | ||
if: ${{ matrix.os == vars.PUBLISH_OS && matrix.config == 'Release' }} | ||
run: dotnet publish --no-build -p:DebugType=None -p:DebugSymbols=false -c ${{ matrix.config }} -f ${{ vars.PYTHON_NETPACKAGE_FRAMEWORK }} -o './src/Python/src/tableau_migration/bin/' '${{ vars.BUILD_PROJECT }}' | ||
- name: Net Publish Tests ${{ matrix.config }} | ||
if: ${{ matrix.os == vars.PUBLISH_OS && matrix.config == 'Release' }} | ||
run: dotnet publish --no-build -p:DebugType=None -p:DebugSymbols=false -c ${{ matrix.config }} -f ${{ vars.PYTHON_NETPACKAGE_FRAMEWORK }} -o './dist/tests/' './tests/Tableau.Migration.Tests/Tableau.Migration.Tests.csproj' | ||
- name: Net Publish TestComponents ${{ matrix.config }} | ||
if: ${{ matrix.os == vars.PUBLISH_OS && matrix.config == 'Release' }} | ||
run: dotnet publish --no-build -p:DebugType=None -p:DebugSymbols=false -c ${{ matrix.config }} -f ${{ vars.PYTHON_NETPACKAGE_FRAMEWORK }} -o './dist/testcomponents/' './tests/Tableau.Migration.TestComponents/Tableau.Migration.TestComponents.csproj' | ||
- name: Upload Published Artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ matrix.os == vars.PUBLISH_OS && matrix.config == 'Release' }} | ||
with: | ||
name: published-${{ matrix.config }} | ||
path: './src/Python/src/tableau_migration/bin/**' | ||
- name: Upload Tests Artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ matrix.os == vars.PUBLISH_OS && matrix.config == 'Release' }} | ||
with: | ||
name: tests-published-${{ matrix.config }} | ||
path: './dist/tests/**' | ||
- name: Upload TestComponents Artifacts | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ matrix.os == vars.PUBLISH_OS && matrix.config == 'Release' }} | ||
with: | ||
name: testcomponents-published-${{ matrix.config }} | ||
path: './dist/testcomponents/**' | ||
- name: Upload Nupkg Artifact | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ matrix.os == vars.PUBLISH_OS && matrix.config == 'Release' }} | ||
with: | ||
name: nuget-package | ||
path: './src/${{ vars.NUGET_PACKAGE_FOLDER }}/bin/${{ matrix.config }}/*.nupkg' | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This workflow will publish a package to a Nuget Repository | ||
name: .Net Publish Package Workflow | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
NUGET_PUBLISH_API_KEY: | ||
required: false | ||
inputs: | ||
published-os: | ||
required: true | ||
type: string | ||
runs-on-config: | ||
required: true | ||
type: string | ||
build-config: | ||
required: true | ||
type: string | ||
publish-environment: | ||
required: true | ||
type: string | ||
package-version: | ||
required: false | ||
type: string | ||
default: '' | ||
|
||
env: | ||
PUBLISH_PACKAGE_KEY: ${{ secrets.NUGET_PUBLISH_API_KEY }} | ||
|
||
jobs: | ||
publish-package: | ||
environment: | ||
name: ${{ inputs.publish-environment }} | ||
runs-on: ${{ inputs.runs-on-config }} | ||
name: Publish Package from ${{ inputs.published-os }} with ${{ inputs.build-config }} configuration | ||
steps: | ||
- uses: actions/checkout@v3 | ||
if: ${{ env.PUBLISH_PACKAGE_KEY != '' }} | ||
- uses: ./.github/actions/setup-dotnet | ||
if: ${{ env.PUBLISH_PACKAGE_KEY != '' && inputs.runs-on-config != 'self-hosted' }} | ||
- uses: actions/download-artifact@v3 | ||
if: ${{ env.PUBLISH_PACKAGE_KEY != '' }} | ||
with: | ||
name: nuget-package | ||
- name: Publish the package to a Nuget Repository | ||
if: ${{ env.PUBLISH_PACKAGE_KEY != '' }} | ||
shell: pwsh | ||
env: | ||
NUGET_API_KEY: ${{ secrets.NUGET_PUBLISH_API_KEY }} | ||
run: dotnet nuget push Tableau.Migration.*.nupkg -k $env:NUGET_API_KEY -s ${{ vars.NUGET_PACKAGE_REPOSITORY }} --skip-duplicate | ||
- name: Remove the package from Nuget Repository | ||
if: ${{ env.PUBLISH_PACKAGE_KEY != '' && inputs.package-version != '' && inputs.publish-environment == 'public-dryrun' }} | ||
shell: pwsh | ||
env: | ||
NUGET_API_KEY: ${{ secrets.NUGET_PUBLISH_API_KEY }} | ||
run: dotnet nuget delete Tableau.Migration '${{ inputs.package-version }}' -k $env:NUGET_API_KEY -s ${{ vars.NUGET_PACKAGE_REPOSITORY }} --non-interactive | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This workflow will test a .NET project | ||
name: .Net Test Workflow | ||
|
||
on: | ||
workflow_call: | ||
|
||
env: | ||
MIGRATIONSDK_BUILD_DOCS: 'no' | ||
MIGRATIONSDK_SKIP_GITHUB_RUNNER_TESTS: ${{ vars.MIGRATIONSDK_SKIP_GITHUB_RUNNER_TESTS }} | ||
MIGRATIONSDK_SKIP_FLAKY_TESTS: ${{ vars.MIGRATIONSDK_SKIP_FLAKY_TESTS }} | ||
MIGRATIONSDK_TEST_CANCELLATION_TIMEOUT_TIMESPAN: ${{ vars.MIGRATIONSDK_TEST_CANCELLATION_TIMEOUT_TIMESPAN }} | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ${{ fromJSON(vars.BUILD_OS) }} | ||
config: ${{ fromJSON(vars.BUILD_CONFIGURATIONS) }} | ||
runs-on: ${{ matrix.os }} | ||
name: .Net Test ${{ matrix.os }}, ${{ matrix.config }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ./.github/actions/setup-dotnet | ||
- name: Test ${{ matrix.config }} | ||
run: | | ||
dotnet test '${{ vars.BUILD_SOLUTION }}' -c ${{ matrix.config }} -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput=./artifacts/ --verbosity normal --logger trx --results-directory "TestResults-${{ matrix.os }}-${{ matrix.config }}" | ||
- name: Upload test results | ||
# Use always() to always run this step to publish test results when there are test failures | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dotnet-results-${{ matrix.os }}-${{ matrix.config }} | ||
path: TestResults-${{ matrix.os }}-${{ matrix.config }} | ||
if-no-files-found: error | ||
- name: Upload Code Coverage | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: coverage-${{ matrix.os }}-${{ matrix.config }} | ||
path: '**/artifacts/coverage*.cobertura.xml' | ||
if-no-files-found: error |
Oops, something went wrong.