Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .github/workflows/release_to_azure_devops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,25 @@ jobs:
run: |
git fetch --tags

LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_ENV
# Get the highest version tag from all tags
HIGHEST_TAG=$(git tag -l | grep '^v[0-9]*\.[0-9]*\.[0-9]*$' | sort -V | tail -1 || echo "v1.0.0")
echo "HIGHEST_TAG=${HIGHEST_TAG}" >> $GITHUB_ENV

IFS='.' read -ra VERSION_PARTS <<< "$LATEST_TAG"
MAJOR=${VERSION_PARTS[0]#v}
# Extract version parts
IFS='.' read -ra VERSION_PARTS <<< "${HIGHEST_TAG#v}"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}

NEXT_MINOR=$((MINOR + 1))
# For PR builds, increment the patch version to ensure uniqueness
# This ensures we always get a higher version than any existing version
NEXT_PATCH=$((PATCH + 1))
EXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
echo "EXT_VERSION=${EXT_VERSION}" >> $GITHUB_ENV

NEXT_VERSION="${MAJOR}.${NEXT_MINOR}.0"
NEXT_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}"
echo "NEXT_VERSION=${NEXT_VERSION}" >> $GITHUB_ENV

SHORT_RUN_ID=$((${{ github.run_id }} % 2147483647))
EXT_VERSION="${MAJOR}.${MINOR}.0.${SHORT_RUN_ID}"
echo "EXT_VERSION=${EXT_VERSION}" >> $GITHUB_ENV

- name: Restore npm packages
run: npm ci
working-directory: src/format-check
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The task has several configurable parameters:
- **StatusCheck**: (Optional, default: false) If set to true, the task will set a status check in the PR when formatting errors are found.
- **StatusCheckName**: (Optional, default: "format check") Name of the status check in the PR for formatting errors.
- **StatusCheckGenre**: (Optional, default: "formatting") Genre of the status check in the PR for formatting errors.
- **ScopeToPullRequest**: (Optional, default: false) When checked, the task only considers failures for files in the pull request.
- **ScopeToPullRequest**: (Optional, default: false) When checked, the task only considers failures for files in the pull request. Additionally, it will only report formatting issues on lines that have been changed in the pull request, which is particularly useful for files with conditional compilation blocks or other platform-specific code.

## How to Use

Expand Down Expand Up @@ -62,6 +62,7 @@ The task has several configurable parameters:
In either case, the task will add comments to the pull request for any issues found by dotnet format.

To scope the task to only files included in the PR, set `ScopeToPullRequest` to true (default: false).
When `ScopeToPullRequest` is set to true, the task will also only report formatting issues on lines that have been changed in the pull request, which is particularly useful for files with conditional compilation blocks or other platform-specific code.

**Note:** Ensure the job running the task has rights to use the OAuth token and that the user running the build has the 'Contribute to Pull Requests' permission.

Expand Down
28 changes: 28 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.json',
stringifyContentPathRegex: String.raw`\.html$`,
},
],
},
transformIgnorePatterns: [
"node_modules/(?!node-fetch)"
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'],
moduleNameMapper: {
'^node-fetch$': require.resolve('node-fetch'),
},
globals: {
'ts-jest': {
tsconfig: 'tsconfig.json',
stringifyContentPathRegex: String.raw`\.html$`,
},
},

};
Loading