From 2ccd169fb0fe4e01c1206e436d2cfb16fb69d525 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Fri, 30 Jan 2026 12:13:37 -0700 Subject: [PATCH] chore: swap makefile for justfile --- .github/workflows/ci.yml | 147 ++++++++++++++++----------------- .github/workflows/release.yml | 14 ++-- Makefile | 149 ---------------------------------- README.md | 14 ++-- justfile | 124 ++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+), 243 deletions(-) delete mode 100644 Makefile create mode 100644 justfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9b25d2f..f32c4084 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,46 +10,43 @@ jobs: lint: runs-on: windows-latest steps: - - uses: actions/checkout@v5 - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: 10.x.x - name: Set up dotnet tools - run: make install install-styleguide + run: just install install-styleguide - name: Check style with dotnet-format - run: make lint + run: just lint Roslyn_Static_Analysis: runs-on: windows-latest steps: - - uses: actions/checkout@v5 - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: 10.x.x - name: Set up dotnet tools - run: make install install-styleguide + run: just install install-styleguide - name: Restore NuGet Packages - run: make restore + run: just restore # This Make step is configured to treat all warnings as errors, so it will fail if any warnings are found - name: Run static analysis - run: make analyze + run: just analyze Security_Code_Scan: runs-on: windows-latest steps: - - uses: actions/checkout@v5 - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: # v6 is needed for the tool to run dotnet-version: | @@ -57,43 +54,41 @@ jobs: 6.x.x - name: Set up dotnet tools and dependencies - run: make install + run: just install - name: Run security analysis - run: make scan + run: just scan Coverage_Requirements: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: 10.x.x - name: Set up dotnet tools and dependencies - run: make install + run: just install - name: Check if test suite coverage meets requirements - run: make coverage-check + run: just coverage-check Upload_Coverage_Report: if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: 10.x.x - name: Set up dotnet tools and dependencies - run: make install + run: just install - name: Generate coverage report - run: make coverage + run: just coverage - name: Upload lcov coverage report to Coveralls uses: coverallsapp/github-action@master @@ -105,18 +100,17 @@ jobs: if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: 10.x.x - name: Install docfx - run: make install-tools + run: just install-tools - name: Generate docs - run: make docs + run: just docs - name: Deploy docs uses: peaceiris/actions-gh-pages@v3 @@ -128,11 +122,11 @@ jobs: # derived from https://dev.to/felipetofoli/github-actions-for-net-full-framework-build-and-test-299h runs-on: windows-latest env: - EASYPOST_TEST_API_KEY: "123" - EASYPOST_PROD_API_KEY: "123" + EASYPOST_TEST_API_KEY: '123' + EASYPOST_PROD_API_KEY: '123' strategy: matrix: - name: ["Net60", "Net70", "Net80", "Net90", "Net100"] + name: ['Net60', 'Net70', 'Net80', 'Net90', 'Net100'] include: - name: Net60 framework: net6.0 @@ -150,12 +144,11 @@ jobs: framework: net10.0 dotnet-version: 10.x.x steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: submodules: true - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: | 10.x.x @@ -163,7 +156,7 @@ jobs: - name: Specify .NET SDK version to use since GitHub runners have multiple installed run: | - echo '{"sdk":{"version": "${{ matrix.dotnet-version }}"}}' > ./global.json + echo '{"sdk":{"version": "${{ matrix.dotnet-version }}"}}' > ./global.json - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 @@ -180,25 +173,24 @@ jobs: ${{ runner.os }}-nuget- - name: Restore NuGet Packages - run: make restore + run: just restore # Pull in fixtures submodule - name: Set up dotnet tools and dependencies - run: make install + run: just install # Run the unit tests in a specific framework (verify that the library works in that framework) - name: Run Tests - run: make unit-test FW=${{ matrix.framework }} + run: just unit-test ${{ matrix.framework }} Integration_Tests: runs-on: windows-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: submodules: true - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: 10.x.x @@ -212,15 +204,15 @@ jobs: uses: darenm/Setup-VSTest@v1.3 - name: Restore NuGet Packages - run: make restore + run: just restore # Pull in fixtures submodule - name: Set up dotnet tools and dependencies - run: make install + run: just install # Run the integration tests - name: Run Tests - run: make integration-test + run: just integration-test # .NET Standard notes: # - NET Standard 2.0 is compatible with minimum .NET Framework 4.6.1: https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0 @@ -235,19 +227,18 @@ jobs: # Need windows-2022 for .NET Framework 4.7.2 support runs-on: windows-2022 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: submodules: true - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 id: setupid with: dotnet-version: 10.x.x - name: Specify .NET SDK version to use since GitHub runners have multiple installed run: | - echo '{"sdk":{"version": "${{ steps.setupid.outputs.dotnet-version }}"}}' > ./global.json + echo '{"sdk":{"version": "${{ steps.setupid.outputs.dotnet-version }}"}}' > ./global.json - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 @@ -260,31 +251,30 @@ jobs: # Pull in fixtures submodule - name: Set up dotnet tools and dependencies - run: make install + run: just install - name: Restore NuGet Packages - run: make restore build + run: just restore build # Run the compatibility tests - name: Run Tests - run: make netstandard-compat-test FW=net472 + run: just netstandard-compat-test net472 FSharp_Compatibility_Tests: runs-on: windows-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: submodules: true - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 id: setupid with: dotnet-version: 10.x.x - name: Specify .NET SDK version to use since GitHub runners have multiple installed run: | - echo '{"sdk":{"version": "${{ steps.setupid.outputs.dotnet-version }}"}}' > ./global.json + echo '{"sdk":{"version": "${{ steps.setupid.outputs.dotnet-version }}"}}' > ./global.json - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 @@ -296,32 +286,31 @@ jobs: uses: darenm/Setup-VSTest@v1.3 - name: Restore NuGet Packages - run: make restore + run: just restore # Pull in fixtures submodule - name: Set up dotnet tools and dependencies - run: make install + run: just install # Run the compatibility tests - name: Run Tests - run: make fs-compat-test + run: just fs-compat-test Visual_Basic_Compatibility_Test: runs-on: windows-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: submodules: true - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 id: setupid with: dotnet-version: 10.x.x - name: Specify .NET SDK version to use since GitHub runners have multiple installed run: | - echo '{"sdk":{"version": "${{ steps.setupid.outputs.dotnet-version }}"}}' > ./global.json + echo '{"sdk":{"version": "${{ steps.setupid.outputs.dotnet-version }}"}}' > ./global.json - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 @@ -333,12 +322,12 @@ jobs: uses: darenm/Setup-VSTest@v1.3 - name: Restore NuGet Packages - run: make restore + run: just restore # Pull in fixtures submodule - name: Set up dotnet tools and dependencies - run: make install + run: just install # Run the compatibility tests - name: Run Tests - run: make vb-compat-test + run: just vb-compat-test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1c7afd7..2173fb07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,11 +10,9 @@ jobs: name: Publish to NuGet runs-on: windows-latest steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Install .NET SDK - uses: actions/setup-dotnet@v5 + - uses: actions/checkout@v6 + - uses: extractions/setup-just@v3 + - uses: actions/setup-dotnet@v5 with: dotnet-version: | 6.x.x @@ -27,10 +25,10 @@ jobs: uses: NuGet/setup-nuget@v2 - name: Restore NuGet Packages - run: make restore + run: just restore - name: Set up dotnet tools and dependencies - run: make install + run: just install - name: Set up authenticity certificate run: | @@ -69,7 +67,7 @@ jobs: shell: cmd - name: Publish to NuGet - run: make publish key=${{ secrets.NUGET_API_KEY }} + run: just publish key=${{ secrets.NUGET_API_KEY }} - name: Upload NuGet package to release uses: AButler/upload-release-assets@v3.0.1 diff --git a/Makefile b/Makefile deleted file mode 100644 index bf8322b1..00000000 --- a/Makefile +++ /dev/null @@ -1,149 +0,0 @@ -FW ?= net10.0 - -## help - Display help about make targets for this Makefile -help: - @cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t - -## analyze - Run static analysis for the project (check CA rule violations) -analyze: - dotnet build EasyPost/EasyPost.csproj -c "Release" -t:Rebuild -restore -p:EnableNETAnalyzers=true -p:CodeAnalysisTreatWarningsAsErrors=true -p:RunAnalyzersDuringBuild=true -p:AnalysisLevel=latest -p:AnalysisMode=Minimum - -## build - Build the project in Debug mode -build: - dotnet build EasyPost/EasyPost.csproj -c "Debug" -t:Rebuild -restore -p:EnableNETAnalyzers=false - -## build-fw - Build the project in Debug mode for a specific framework -# @parameters: -# FW= - The framework to build for. -build-fw: - dotnet build EasyPost/EasyPost.csproj -c "Debug" -t:Rebuild -restore -f ${FW} -p:EnableNETAnalyzers=false - -## build-prod - Build the project in Release mode -build-prod: - dotnet build EasyPost/EasyPost.csproj -c "Release" -t:Rebuild -restore -p:EnableNETAnalyzers=false - -## clean - Clean the project -clean: - dotnet clean - -## coverage - Generate coverage reports (unit tests, not integration) for the project -coverage: - ./scripts/unix/generate_test_reports.sh - -## coverage-check - Check if the coverage is above the minimum threshold -coverage-check: - ./scripts/unix/check_coverage.sh 85 - -## docs - Generates library documentation -docs: - dotnet tool run docfx docs/docfx.json - -## init-examples-submodule - Initialize the examples submodule -init-examples-submodule: - git submodule init - git submodule update - -## install-tools - Install required dotnet tools -install-tools: - dotnet new tool-manifest --force || exit 0 - dotnet tool install --local security-scan --version 5.6.3 || exit 0 - dotnet tool install --local dotnet-format || exit 0 - dotnet tool install --local docfx --version 2.60.2 || exit 0 - -## install-styleguide - Import style guide (Unix only) -install-styleguide: | init-examples-submodule - sh examples/symlink_directory_files.sh examples/style_guides/csharp . - -## install - Install requirements -install: | install-tools init-examples-submodule - -## lint - Lints the solution (EasyPost + Tests + Integration + F#/VB compatibilities) (check IDE and SA rule violations) -## @parameters: -## FW= - The framework to build for. -lint: - # Lint the project code with dotnet-format - dotnet tool run dotnet-format --no-restore --check - # Lint the source code (only EasyPost, no tests et. al) by building with the "Linting" configuration (will trigger StyleCop) - dotnet build EasyPost/EasyPost.csproj -c "Linting" -t:Rebuild -restore -p:EnforceCodeStyleInBuild=true -f ${FW} - -## lint-fix - Formats the project -lint-fix: - dotnet tool run dotnet-format --no-restore - -## lint-scripts - Lint and validate the Batch scripts (Windows only) -lint-scripts: - scripts\win\lint_scripts.bat - -## publish - Publish the project to NuGet -# @parameters: -# key= - The NuGet API key to use for publishing. -# ref: https://learn.microsoft.com/en-us/nuget/reference/cli-reference/cli-ref-push -publish: - # Verify that no extraneous .nupkg files exist - dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key ${key} --skip-duplicate - -## release - Cuts a release for the project on GitHub (requires GitHub CLI) -# tag = The associated tag title of the release -# target = Target branch or full commit SHA -release: - gh release create ${tag} --target ${target} - -## restore - Restore the project -restore: - dotnet restore - -## scan - Scan the solution (EasyPost + Tests + Integration + F#/VB compatibilities) for security issues (must run install-scanner first) -scan: - dotnet tool run security-scan --verbose --no-banner --ignore-msbuild-errors EasyPost.sln - # "--ignore-msbuild-errors" needed since MSBuild does not like F#: https://github.com/security-code-scan/security-code-scan/issues/235 - -## setup-win - Install required .NET versions and tools (Windows only) -setup-win: - scripts\win\setup.bat - -## setup-unix - Install required .NET versions and tools (Unix only) -setup-unix: - ./scripts/unix/setup.sh - -## test - Run all tests in all projects in all configured frameworks (unit + integration + compatibility) -test: - dotnet test - -## unit-test - Run the unit tests for a specific framework -## Always run unit tests in Debug mode to allow access to internal members -## @parameters: -## FW= - The framework to build for. -unit-test: - dotnet test EasyPost.Tests/EasyPost.Tests.csproj -f ${FW} -c "Debug" - -## update-examples-submodule - Update the examples submodule -update-examples-submodule: - git submodule init - git submodule update --remote - -## integration-test - Run the integration tests for a specific framework -## Always run integration tests in Release mode to check the end-user experience -## @parameters: -## FW= - The framework to build for. -integration-test: - dotnet test EasyPost.Integration/EasyPost.Integration.csproj -f ${FW} -c "Release" -restore - -## fs-compat-test - Run the F# compatibility tests for a specific framework -## @parameters: -## FW= - The framework to build for. -fs-compat-test: - dotnet test EasyPost.Compatibility.FSharp/EasyPost.Compatibility.FSharp.fsproj -f ${FW} -restore - -## vb-compat-test - Run the VB compatibility tests for a specific framework -## @parameters: -## FW= - The framework to build for. -vb-compat-test: - dotnet test EasyPost.Compatibility.VB/EasyPost.Compatibility.VB.vbproj -f ${FW} -restore - -## netstandard-compat-test - Run the Net Standard compatibility tests for a specific framework -## @parameters: -## FW= - The framework to build for. -netstandard-compat-test: - dotnet test EasyPost.Compatibility.NetStandard/EasyPost.Compatibility.NetStandard.csproj -f ${FW} -restore - -.PHONY: help analyze build build-fw build-prod clean coverage coverage-check docs format init-examples-submodule install-styleguide install-tools install lint lint-scripts release restore scan setup-win setup-unix test update-examples-submodule unit-test integration-test fs-compat-test vb-compat-test netstandard-compat-test diff --git a/README.md b/README.md index dbf6b786..430ba838 100644 --- a/README.md +++ b/README.md @@ -263,18 +263,18 @@ such as building, cleaning, and testing can be done via the GUI. ```bash # Build project -make build +just build # Lint project -make lint -make lint-fix +just lint +just lint-fix # Run tests (recommended to instead run via an IDE like Visual Studio) -EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make test -EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make coverage +EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... just test +EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... just coverage # Run security analysis -make scan +just scan ``` #### NuGet Dependencies @@ -327,7 +327,7 @@ Some tests may require a user with a particular set of enabled features such as referrals. We have attempted to call out these functions in their respective docstrings. **NOTE** .NET Framework/.NET Standard unit tests cannot currently be run on Apple Silicon (M1, M2, etc.). Instead, run -unit tests in one framework at a time with, e.g `make unit-test fw=net9.0`. Valid frameworks: +unit tests in one framework at a time with, e.g `just unit-test net10.0`. Valid frameworks: - `net472` (.NET Framework 4.7.2, the oldest non-EOL version of .NET Framework; will not run on Apple Silicon) - `net6.0` (.NET 6.0) diff --git a/justfile b/justfile new file mode 100644 index 00000000..18ae6a86 --- /dev/null +++ b/justfile @@ -0,0 +1,124 @@ +FW := "net10.0" + +# Run static analysis for the project (check CA rule violations) +analyze: + dotnet build EasyPost/EasyPost.csproj -c Release -t:Rebuild -restore -p:EnableNETAnalyzers=true -p:CodeAnalysisTreatWarningsAsErrors=true -p:RunAnalyzersDuringBuild=true -p:AnalysisLevel=latest -p:AnalysisMode=Minimum + +# Build the project in Debug mode +build: + dotnet build EasyPost/EasyPost.csproj -c Debug -t:Rebuild -restore -p:EnableNETAnalyzers=false + +# Build the project in Debug mode for a specific framework +build-fw fw=FW: + dotnet build EasyPost/EasyPost.csproj -c Debug -t:Rebuild -restore -f {{fw}} -p:EnableNETAnalyzers=false + +# Build the project in Release mode +build-prod: + dotnet build EasyPost/EasyPost.csproj -c Release -t:Rebuild -restore -p:EnableNETAnalyzers=false + +# Clean the project +clean: + dotnet clean + +# Generate coverage reports (unit tests, not integration) for the project +coverage: + ./scripts/unix/generate_test_reports.sh + +# Check if the coverage is above the minimum threshold +coverage-check: + ./scripts/unix/check_coverage.sh 85 + +# Generates library documentation +docs: + dotnet tool run docfx docs/docfx.json + +# Initialize the examples submodule +init-examples-submodule: + git submodule init + git submodule update + +# Install required dotnet tools +install-tools: + dotnet new tool-manifest --force || exit 0 + dotnet tool install --local security-scan --version 5.6.3 || exit 0 + dotnet tool install --local dotnet-format || exit 0 + dotnet tool install --local docfx --version 2.60.2 || exit 0 + +# Import style guide (Unix only) +install-styleguide: init-examples-submodule + sh examples/symlink_directory_files.sh examples/style_guides/csharp . + +# Install requirements +install: install-tools init-examples-submodule + +# Lints the solution (EasyPost + Tests + Integration + F#/VB compatibilities) (check IDE and SA rule violations) +lint fw=FW: + # Lint the project code with dotnet-format + dotnet tool run dotnet-format --no-restore --check + # Lint the source code (only EasyPost, no tests et. al) by building with the "Linting" configuration (will trigger StyleCop) + dotnet build EasyPost/EasyPost.csproj -c Linting -t:Rebuild -restore -p:EnforceCodeStyleInBuild=true -f {{fw}} + +# Formats the project +lint-fix: + dotnet tool run dotnet-format --no-restore + +# Lint and validate the Batch scripts (Windows only) +lint-scripts: + scripts\win\lint_scripts.bat + +# Publish the project to NuGet +# key: The NuGet API key to use for publishing. +publish key: + dotnet nuget push *.nupkg --source https://api.nuget.org/v3/index.json --api-key {{key}} --skip-duplicate + +# Cuts a release for the project on GitHub (requires GitHub CLI) +# tag: The associated tag title of the release +# target: Target branch or full commit SHA +release tag target: + gh release create {{tag}} --target {{target}} + +# Restore the project +restore: + dotnet restore + +# Scan the solution (EasyPost + Tests + Integration + F#/VB compatibilities) for security issues (must run install-scanner first) +scan: + dotnet tool run security-scan --verbose --no-banner --ignore-msbuild-errors EasyPost.sln + +# Install required .NET versions and tools (Windows only) +setup-win: + scripts\win\setup.bat + +# Install required .NET versions and tools (Unix only) +setup-unix: + ./scripts/unix/setup.sh + +# Run all tests in all projects in all configured frameworks (unit + integration + compatibility) +test: + dotnet test + +# Run the unit tests for a specific framework +# Always run unit tests in Debug mode to allow access to internal members +unit-test fw=FW: + dotnet test EasyPost.Tests/EasyPost.Tests.csproj -f {{fw}} -c Debug + +# Update the examples submodule +update-examples-submodule: + git submodule init + git submodule update --remote + +# Run the integration tests for a specific framework +# Always run integration tests in Release mode to check the end-user experience +integration-test fw=FW: + dotnet test EasyPost.Integration/EasyPost.Integration.csproj -f {{fw}} -c Release -restore + +# Run the F# compatibility tests for a specific framework +fs-compat-test fw=FW: + dotnet test EasyPost.Compatibility.FSharp/EasyPost.Compatibility.FSharp.fsproj -f {{fw}} -restore +# Run the VB compatibility tests for a specific framework +vb-compat-test fw=FW: + dotnet test EasyPost.Compatibility.VB/EasyPost.Compatibility.VB.vbproj -f {{fw}} -restore + +# Run the Net Standard compatibility tests for a specific framework +netstandard-compat-test fw=FW: + dotnet test EasyPost.Compatibility.NetStandard/EasyPost.Compatibility.NetStandard.csproj -f {{fw}} -restore