diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml deleted file mode 100644 index 8faa4d2..0000000 --- a/.github/workflows/pipeline.yml +++ /dev/null @@ -1,140 +0,0 @@ -name: "build-test (old)" -on: # rebuild any PRs and main branch changes - pull_request: - branches: [main] - push: - branches: - - main - - "releases/*" - paths: - - "src/**" - - "package.json" - -jobs: - Build: # make sure build/ci work properly - name: Build - runs-on: ubuntu-latest - strategy: - matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest - node: ["18"] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # 0 indicates all history for all branches and tags - - name: GitVersion - id: gitversion # step id used as reference for output values - uses: roryprimrose/rungitversion@v1 - - name: Output version values - run: | - # These are also available as environment variables, e.g. GitVersion_Major, or GitVersion_NuGetVersionV2 - echo "Major: ${{ steps.gitversion.outputs.Major }}" - echo "Minor: ${{ steps.gitversion.outputs.Minor }}" - echo "Patch: ${{ steps.gitversion.outputs.Patch }}" - echo "PreReleaseTag: ${{ steps.gitversion.outputs.PreReleaseTag }}" - echo "PreReleaseTagWithDash: ${{ steps.gitversion.outputs.PreReleaseTagWithDash }}" - echo "PreReleaseLabel: ${{ steps.gitversion.outputs.PreReleaseLabel }}" - echo "PreReleaseNumber: ${{ steps.gitversion.outputs.PreReleaseNumber }}" - echo "WeightedPreReleaseNumber: ${{ steps.gitversion.outputs.WeightedPreReleaseNumber }}" - echo "BuildMetaData: ${{ steps.gitversion.outputs.BuildMetaData }}" - echo "BuildMetaDataPadded: ${{ steps.gitversion.outputs.BuildMetaDataPadded }}" - echo "FullBuildMetaData: ${{ steps.gitversion.outputs.FullBuildMetaData }}" - echo "MajorMinorPatch: ${{ steps.gitversion.outputs.MajorMinorPatch }}" - echo "SemVer: ${{ steps.gitversion.outputs.SemVer }}" - echo "LegacySemVer: ${{ steps.gitversion.outputs.LegacySemVer }}" - echo "LegacySemVerPadded: ${{ steps.gitversion.outputs.LegacySemVerPadded }}" - echo "AssemblySemVer: ${{ steps.gitversion.outputs.AssemblySemVer }}" - echo "AssemblySemFileVer: ${{ steps.gitversion.outputs.AssemblySemFileVer }}" - echo "FullSemVer: ${{ steps.gitversion.outputs.FullSemVer }}" - echo "InformationalVersion: ${{ steps.gitversion.outputs.InformationalVersion }}" - echo "BranchName: ${{ steps.gitversion.outputs.BranchName }}" - echo "Sha: ${{ steps.gitversion.outputs.Sha }}" - echo "ShortSha: ${{ steps.gitversion.outputs.ShortSha }}" - echo "NuGetVersionV2: ${{ steps.gitversion.outputs.NuGetVersionV2 }}" - echo "NuGetVersion: ${{ steps.gitversion.outputs.NuGetVersion }}" - echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.NuGetPreReleaseTagV2 }}" - echo "NuGetPreReleaseTag: ${{ steps.gitversion.outputs.NuGetPreReleaseTag }}" - echo "VersionSourceSha: ${{ steps.gitversion.outputs.VersionSourceSha }}" - echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" - echo "CommitsSinceVersionSourcePadded: ${{ steps.gitversion.outputs.CommitsSinceVersionSourcePadded }}" - echo "CommitDate: ${{ steps.gitversion.outputs.CommitDate }}" - - name: Setup node v${{ matrix.node }} - uses: actions/setup-node@v4 # https://github.com/actions/setup-node - with: - node-version: ${{ matrix.node }} - cache: npm - - name: Install npm@latest - run: | - sudo npm install --global npm@latest - - name: Install dependencies - run: | - npm install - - name: Output Relabeler semantic version - run: | - echo $GitVersion_NuGetVersionV2 - - run: | - npm run all - - Test: # run just the tests - name: Test - runs-on: ubuntu-latest - strategy: - matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest - node: ["18"] - steps: - - uses: actions/checkout@v4 - - name: Setup node v${{ matrix.node }} - uses: actions/setup-node@v4 # https://github.com/actions/setup-node - with: - node-version: ${{ matrix.node }} - cache: npm - - run: | - sudo npm install --global npm@latest - npm install - - run: npm run build - - run: npm test - - # Make sure the action works on a clean machine without building. - # This should be run on branches Releases/* in the future and - # 'build run package' should have been run prior. - Execute: - name: Execute - runs-on: ubuntu-latest - strategy: - matrix: - os: - - ubuntu-latest - - macos-latest - - windows-latest - node: ["18"] - steps: - - name: Checkout repository code - uses: actions/checkout@v4 - - name: Setup node v${{ matrix.node }} - uses: actions/setup-node@v4 # https://github.com/actions/setup-node - with: - node-version: ${{ matrix.node }} - cache: npm - - name: Install npm@latest - run: | - sudo npm install --global npm@latest - - name: Install dependencies - run: | - npm install - - name: Build & Package - run: | - npm run build - npm run package - - name: Execute action Relabeler - uses: ./ - with: - milliseconds: 1200 - repositoryToken: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 383d639..e974897 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,7 @@ on: jobs: relabel: + name: Relabeler Tests runs-on: ubuntu-latest steps: - name: Checkout code @@ -29,10 +30,21 @@ jobs: run: npm ci - name: Build project - run: npm run build # Assumes you have a build script in package.json + run: npm run build - name: Test - run: npm test + run: | + npm test + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage/lcov.info # cSpell: ignore lcov + #token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests # cSpell: ignore unittests + name: relabeler-tests + verbose: true + fail_ci_if_error: true - name: Create artifact run: | @@ -46,7 +58,13 @@ jobs: path: artifact/ - name: Run Relabeler + id: relabeler uses: ./ # This uses the action from the root of the branch or PR with: who-to-greet: "GitHub" repositoryToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Print Relabeler Outputs + run: | + echo "Repository: ${{ steps.relabeler.outputs.repository }}" + echo "Time: ${{ steps.relabeler.outputs.time }}" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0dda78e..577a66b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,47 +11,53 @@ pr: - main pool: - vmImage: 'ubuntu-latest' + vmImage: "ubuntu-latest" steps: -- task: NodeTool@0 - inputs: - versionSpec: '18.x' - displayName: 'Install Node.js' - -- script: | - npm install - displayName: 'npm install' - -- script: | - npm run build - displayName: 'npm build' - -- script: | - npm test - displayName: 'npm test' - -- task: PublishTestResults@2 - condition: succeededOrFailed() - inputs: - testResultsFormat: 'JUnit' - testResultsFiles: '**/TEST-*.xml' - -- task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'Cobertura' # cSpell: ignore Cobertura - summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/*coverage.xml' - -- task: ArchiveFiles@2 - inputs: - rootFolderOrFile: '$(System.DefaultWorkingDirectory)/build' - includeRootFolder: false - archiveType: 'zip' - archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' - replaceExistingArchive: true - -- task: PublishPipelineArtifact@1 - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)' - artifact: 'drop' - publishLocation: 'pipeline' + - task: NodeTool@0 + inputs: + versionSpec: "18.x" + displayName: "Install Node.js" + + - script: | + npm install + displayName: "npm install" + + - script: | + npm run build + displayName: "npm build" + + - script: | + npm test + displayName: "npm test and coverage" + + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFormat: "JUnit" + testResultsFiles: "**/TEST-*.xml" + + - task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: "Cobertura" # cSpell: ignore Cobertura + summaryFileLocation: "$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml" + + - task: PublishPipelineArtifact@1 + inputs: + targetPath: "$(System.DefaultWorkingDirectory)/coverage/cobertura-coverage.xml" + artifact: "coverage-report" + publishLocation: "pipeline" + + - task: ArchiveFiles@2 + inputs: + rootFolderOrFile: "$(System.DefaultWorkingDirectory)/dist" + includeRootFolder: false + archiveType: "zip" + archiveFile: "$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip" + replaceExistingArchive: true + + - task: PublishPipelineArtifact@1 + inputs: + targetPath: "$(Build.ArtifactStagingDirectory)" + artifact: "build-artifact" + publishLocation: "pipeline" diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..8c96964 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,36 @@ +coverage: + status: + project: + default: + # Thresholds for overall project coverage + target: 80% # Set your desired coverage target + threshold: 1% # Allowable drop in coverage + patch: + default: + # Thresholds for coverage of new changes + target: 80% # Set your desired coverage target for new changes + threshold: 5% # Allowable drop in coverage for new changes + +comment: + layout: "reach, diff, flags, files" + behavior: default + require_changes: false + +parsers: + gcov: + branch_detection: + conditional: yes + loop: yes + method: no + macro: no + +flags: + unittests: + paths: + - "src/" + +# Exclude specific files or directories from coverage +ignore: + - "__tests__/" + - "node_modules/" + - "dist/" diff --git a/jest.config.mjs b/jest.config.mjs index 91af491..f6097fa 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -7,5 +7,5 @@ export default { }, collectCoverage: true, coverageDirectory: 'coverage', - coverageReporters: ['cobertura', 'text'] // cSpell: ignore cobertura -}; + coverageReporters: ['lcov', 'text', 'cobertura'], // Generates both LCOV and Cobertura reports +}; // cSpell: ignore lcov cobertura