From b2d384ba25035262553aa2ce9605854bac93171e Mon Sep 17 00:00:00 2001 From: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:58:51 -0800 Subject: [PATCH] chore: Add github CI and release-please. --- .circleci/config.yml | 84 ------------------- .github/actions/build-docs/action.yml | 13 +++ .github/actions/ci/action.yml | 39 +++++++++ .github/actions/publish-docs/action.yml | 19 +++++ .github/workflows/ci.yml | 22 +++++ .github/workflows/lint-pr-title.yml | 12 +++ .github/workflows/manual-publish-docs.yml | 21 +++++ .github/workflows/manual-publish.yml | 43 ++++++++++ .github/workflows/release-please.yml | 54 ++++++++++++ .gitignore | 4 + docfx.json | 38 +++++++++ docs-src/index.md => index.md | 0 .../LaunchDarkly.Logging.NLog.csproj | 10 +-- .../LaunchDarkly.Logging.NLog.Tests.csproj | 2 +- toc.yml | 2 + 15 files changed, 273 insertions(+), 90 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/actions/build-docs/action.yml create mode 100644 .github/actions/ci/action.yml create mode 100644 .github/actions/publish-docs/action.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/lint-pr-title.yml create mode 100644 .github/workflows/manual-publish-docs.yml create mode 100644 .github/workflows/manual-publish.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 docfx.json rename docs-src/index.md => index.md (100%) create mode 100644 toc.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 3f012f3..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,84 +0,0 @@ -version: 2.1 - -orbs: - win: circleci/windows@2.4.0 - -workflows: - version: 2 - test: - jobs: - - build-test-linux: - name: .NET Core 2.1 - Linux - docker-image: mcr.microsoft.com/dotnet/core/sdk:2.1-focal - build-target-framework: netstandard2.0 - test-target-framework: netcoreapp2.1 - - build-test-linux: - name: .NET Core 3.1 - Linux - docker-image: mcr.microsoft.com/dotnet/core/sdk:3.1-focal - build-target-framework: netstandard2.0 - test-target-framework: netcoreapp3.1 - - build-test-linux: - name: .NET 5.0 - Linux - docker-image: mcr.microsoft.com/dotnet/sdk:5.0-focal - build-target-framework: netstandard2.0 - test-target-framework: net5.0 - - build-test-windows: - name: .NET Framework 4.5.2 - Windows - build-target-framework: net452 - test-target-framework: net452 - - build-test-windows: - name: .NET Framework 4.6.1 - Windows - build-target-framework: net452 - test-target-framework: net461 - -jobs: - build-test-linux: - parameters: - docker-image: - type: string - build-target-framework: - type: string - test-target-framework: - type: string - docker: - - image: <> - environment: - ASPNETCORE_SUPPRESSSTATUSMESSAGES: true - BUILDFRAMEWORKS: <> - TESTFRAMEWORK: <> - steps: - - checkout - - run: - name: restore dependencies - command: dotnet restore src/LaunchDarkly.Logging.NLog - - run: - name: build - command: dotnet build src/LaunchDarkly.Logging.NLog - - run: - name: run tests - command: dotnet test test/LaunchDarkly.Logging.NLog.Tests - - build-test-windows: - parameters: - build-target-framework: - type: string - test-target-framework: - type: string - executor: - name: win/default - shell: powershell.exe - environment: - ASPNETCORE_SUPPRESSSTATUSMESSAGES: true - BUILDFRAMEWORKS: <> - TESTFRAMEWORK: <> - steps: - - checkout - - run: - name: restore dependencies - command: dotnet restore src/LaunchDarkly.Logging.NLog - - run: - name: build - command: dotnet build src/LaunchDarkly.Logging.NLog - - run: - name: run tests - command: dotnet test test/LaunchDarkly.Logging.NLog.Tests diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml new file mode 100644 index 0000000..5a557a8 --- /dev/null +++ b/.github/actions/build-docs/action.yml @@ -0,0 +1,13 @@ +# Use a step like this to build documentation. +name: Build Documentation +description: 'Build Documentation.' + +runs: + using: composite + steps: + - name: Build Documentation + shell: bash + run: | + dotnet tool update -g docfx + docfx metadata + docfx build diff --git a/.github/actions/ci/action.yml b/.github/actions/ci/action.yml new file mode 100644 index 0000000..79d26cd --- /dev/null +++ b/.github/actions/ci/action.yml @@ -0,0 +1,39 @@ +# This is a composite to allow sharing these steps into other workflows. +# For instance it could be used by regular CI as well as the release process. + +name: CI Workflow +description: 'Shared CI workflow.' +inputs: + run_tests: + description: 'If true, run unit tests, otherwise skip them.' + required: false + default: 'true' + +runs: + using: composite + steps: + - name: Setup dotnet build tools + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0 + + - name: Restore dotnet dependencies + shell: bash + id: restore + run: dotnet restore + + - name: Build + shell: bash + id: build + run: dotnet build + + - name: Run Tests + if: steps.build.outcome == 'success' && inputs.run_tests == 'true' + shell: bash + run: dotnet test + + # We build documentation during CI to ensure it can always build prior to a + # release. + - name: Build documentation + if: steps.build.outcome == 'success' + uses: ./.github/actions/build-docs diff --git a/.github/actions/publish-docs/action.yml b/.github/actions/publish-docs/action.yml new file mode 100644 index 0000000..7cc2255 --- /dev/null +++ b/.github/actions/publish-docs/action.yml @@ -0,0 +1,19 @@ +# Publish to github pages or to a different documentation system. + +name: Publish Documentation +description: 'Publish the documentation to X' +inputs: + token: + description: 'Token to use for publishing.' + required: true + +runs: + using: composite + steps: + # This publishes a 'docs' folder to github pages. If you need to publish another way, + # then you can just script it here, or call a script. + - uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.1 + name: 'Publish to Github pages' + with: + docs_path: docs + github_token: { token } # For the shared action the token should be a GITHUB_TOKEN diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..45631fc --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +name: Run CI +on: + workflow_dispatch: + push: + branches: [ 'rlamb/github-ci-and-release' ] + paths-ignore: + - '**.md' # Do not need to run CI for markdown changes. + pull_request: + branches: [ 'rlamb/github-ci-and-release' ] + paths-ignore: + - '**.md' + +jobs: + ci-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # If you only need the current version keep this. + + - uses: ./.github/actions/ci diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml new file mode 100644 index 0000000..4ba79c1 --- /dev/null +++ b/.github/workflows/lint-pr-title.yml @@ -0,0 +1,12 @@ +name: Lint PR title + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + lint-pr-title: + uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main diff --git a/.github/workflows/manual-publish-docs.yml b/.github/workflows/manual-publish-docs.yml new file mode 100644 index 0000000..9ee0cfe --- /dev/null +++ b/.github/workflows/manual-publish-docs.yml @@ -0,0 +1,21 @@ +on: + workflow_dispatch: + +name: Publish Documentation +jobs: + build-publish: + runs-on: ubuntu-latest + permissions: + id-token: write # Needed if using OIDC to get release secrets. + contents: write # Needed in this case to write github pages. + steps: + - uses: actions/checkout@v4 + - id: build + name: Build and Test + uses: ./.github/actions/ci + + - id: publish + name: Publish Documentation + uses: ./.github/actions/publish-docs + with: + token: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/manual-publish.yml b/.github/workflows/manual-publish.yml new file mode 100644 index 0000000..a348484 --- /dev/null +++ b/.github/workflows/manual-publish.yml @@ -0,0 +1,43 @@ +name: Publish Package +on: + workflow_dispatch: + inputs: + prerelease: + description: 'Is this a prerelease.' # use this to control publish tag, for instance NPM wouldn't set latest. + type: boolean + required: true + dry_run: + description: 'Is this a dry run. If so no package will be published.' + type: boolean + required: true + +jobs: + build-publish: + runs-on: ubuntu-latest + # Needed to get tokens during publishing. + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - id: build-and-test + # Build using the same steps from CI. + name: Build and Test + uses: ./.github/actions/ci + + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.0 + name: 'Get your token!' + with: + # The AWS_ROLE_ARN needs added as a var to your repo. + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} + # This example uses the node release token, it will get set into the NODE_AUTH_TOKEN + # environment variable. The action readme contains more information. + ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN' + + - id: publish + name: Publish Package + uses: ./.github/actions/publish + with: + token: "Put your release secret or github token here." + prerelease: ${{ inputs.prerelease }} + dry_run: ${{ inputs.dry_run }} diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..4e7b148 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,54 @@ +name: Run Release Please + +on: + push: + branches: + - main + +jobs: + release-package: + runs-on: ubuntu-latest + permissions: + id-token: write # Needed if using OIDC to get release secrets. + contents: write # Contents and pull-requests are for release-please to make releases. + pull-requests: write + steps: + - uses: google-github-actions/release-please-action@v3 + id: release + with: + command: manifest + token: ${{secrets.GITHUB_TOKEN}} + default-branch: main + + - uses: actions/checkout@v4 + if: ${{ steps.release.outputs.releases_created }} + with: + fetch-depth: 0 # If you only need the current version remove this line. + + - uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.0 + if: ${{ steps.release.outputs.releases_created }} + name: 'Get your token!' + with: + # The AWS_ROLE_ARN needs added as a var to your repo. + aws_assume_role: ${{ vars.AWS_ROLE_ARN }} + # This example uses the node release token, it will get set into the NODE_AUTH_TOKEN + # environment variable. The action readme contains more information. + ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN' + + - uses: ./.github/actions/ci + if: ${{ steps.release.outputs.releases_created }} + + - uses: ./.github/actions/publish + if: ${{ steps.release.outputs.releases_created }} + with: + # If publishing somewhere else, then get the token from SSM. If you need both github, + # and another token, then add more tokens to the composite action. Could be $NODE_AUTH_TOKEN + # from the release-secrets action earlier in this workflow. + token: ${{secrets.GITHUB_TOKEN}} + + - uses: ./.github/actions/publish-docs + if: ${{ steps.release.outputs.releases_created }} + with: + # If publishing somewhere else, then get the token from SSM. If you need both github, + # and another token, then add more tokens to the composite action. + token: ${{secrets.GITHUB_TOKEN}} diff --git a/.gitignore b/.gitignore index d631b75..b07483b 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,7 @@ project.lock.json *.snk *.p12 + +_site/ +docs/ +api/ diff --git a/docfx.json b/docfx.json new file mode 100644 index 0000000..3598861 --- /dev/null +++ b/docfx.json @@ -0,0 +1,38 @@ +{ + "metadata": [ + { + "src": [ + { + "src": "./src", + "files": [ + "**/*.csproj" + ] + } + ], + "dest": "./api" + } + ], + "build": { + "content": [ + { + "files": [ + "**/*.{md,yml}" + ], + "exclude": [ + "docs/**" + ] + } + ], + "output": "docs", + "template": [ + "default", + "modern" + ], + "globalMetadata": { + "_appName": "Launchdarkly Logging Adapter For NLog", + "_appTitle": "Launchdarkly Logging Adapter For NLog", + "_enableSearch": true, + "pdf": false + } + } +} diff --git a/docs-src/index.md b/index.md similarity index 100% rename from docs-src/index.md rename to index.md diff --git a/src/LaunchDarkly.Logging.NLog/LaunchDarkly.Logging.NLog.csproj b/src/LaunchDarkly.Logging.NLog/LaunchDarkly.Logging.NLog.csproj index 1e2a119..eff774b 100644 --- a/src/LaunchDarkly.Logging.NLog/LaunchDarkly.Logging.NLog.csproj +++ b/src/LaunchDarkly.Logging.NLog/LaunchDarkly.Logging.NLog.csproj @@ -7,7 +7,7 @@ SDKs which do not consider "net5.0" to be a valid target framework that can be referenced in a project file. --> - netstandard2.0;net452 + netstandard2.0;net462 $(BUILDFRAMEWORKS) portable LaunchDarkly.Logging.NLog @@ -31,10 +31,10 @@ - - ../../LaunchDarkly.Logging.snk - true - + + + + bin\$(Configuration)\$(TargetFramework)\LaunchDarkly.Logging.NLog.xml diff --git a/test/LaunchDarkly.Logging.NLog.Tests/LaunchDarkly.Logging.NLog.Tests.csproj b/test/LaunchDarkly.Logging.NLog.Tests/LaunchDarkly.Logging.NLog.Tests.csproj index 61acd9c..3fd495d 100644 --- a/test/LaunchDarkly.Logging.NLog.Tests/LaunchDarkly.Logging.NLog.Tests.csproj +++ b/test/LaunchDarkly.Logging.NLog.Tests/LaunchDarkly.Logging.NLog.Tests.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1;net5.0 + net7.0 $(TESTFRAMEWORK) LaunchDarkly.Logging.NLog.Tests diff --git a/toc.yml b/toc.yml new file mode 100644 index 0000000..1a5e7a2 --- /dev/null +++ b/toc.yml @@ -0,0 +1,2 @@ +- name: API + href: api/