From 0bb2c90b0094be8bbfd5e19b28546bd5cf83740f Mon Sep 17 00:00:00 2001 From: s2quake Date: Mon, 17 Jun 2024 21:50:35 +0900 Subject: [PATCH] ci: Improve build and test action --- .github/workflows/build-and-test.yml | 40 ++++++++++++++++++---------- .gitignore | 9 +++---- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9a0b79a..94341fa 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -3,27 +3,39 @@ name: Build and Test on: pull_request: +env: + TEST_RESULTS_PATH: ${{ github.workspace }}/test-results.trx + +permissions: + contents: read + actions: read + checks: write + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.7 - - uses: actions/setup-dotnet@v4.0.0 + - name: Checkout code + uses: actions/checkout@v4.1.7 + - name: Setup .NET + uses: actions/setup-dotnet@v4.0.0 with: dotnet-version: 8.0.100 - - run: dotnet build --configuration Release - - run: | - dotnet test --configuration Release --no-restore --no-build \ - --logger "trx;LogFileName=${{ github.workspace }}/logs/test-results.trx" - - run: echo "PWD=$(pwd)" >> $GITHUB_ENV - - uses: dorny/test-reporter@v1 + - name: Dotnet Build + run: dotnet build --configuration Release + - name: Dotnet Test + run: | + dotnet test --configuration Release --no-restore --no-build --logger "trx;LogFileName=${{ env.TEST_RESULTS_PATH }}" + - name: Upload test results + uses: actions/upload-artifact@v4 if: success() || failure() with: - name: XUnit Tests - path: ${{ github.workspace }}/logs/test-results.trx - reporter: dotnet-trx - - uses: actions/upload-artifact@v4 + name: test-results + path: ${{ env.TEST_RESULTS_PATH }} + - name: Upload test results + uses: dorny/test-reporter@v1.9.1 if: success() || failure() with: - name: test-results - path: ${{ github.workspace }}/logs/test-results.trx + name: XUnit Tests + path: ${{ env.TEST_RESULTS_PATH }} + reporter: dotnet-trx diff --git a/.gitignore b/.gitignore index 3aaf353..719b22c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +.vs/ +.vscode/ +.example/ bin/ publish/ pack/ @@ -27,10 +30,6 @@ obj/ logs/ packages/ .DS_Store -.vs/ -.vscode/ *.user *.suo -launchSettings.json -build-temp.ps1 -.example/ \ No newline at end of file +test-results.trx \ No newline at end of file