diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..87a729d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release + +on: + push: + branches: [main] + +jobs: + release: + name: Bump version and release + runs-on: self-hosted + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 # necesario para leer tags y changelog + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Run tests before release + run: wolframscript -file tests/RunAllTests.wl + + - name: Read current version + id: version + run: | + VERSION=$(cat QMB/version.txt | tr -d '[:space:]') + echo "current=$VERSION" >> $GITHUB_OUTPUT + + - name: Bump patch version + id: bump + run: | + VERSION=${{ steps.version.outputs.current }} + MAJOR=$(echo $VERSION | cut -d. -f1) + MINOR=$(echo $VERSION | cut -d. -f2) + PATCH=$(echo $VERSION | cut -d. -f3) + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" + echo "$NEW_VERSION" > QMB/version.txt + echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT + + - name: Update PacletInfo.wl + run: | + sed -i 's/Version -> "[^"]*"/Version -> "${{ steps.bump.outputs.new }}"/' QMB/PacletInfo.wl + + - name: Commit version bump + run: | + git config user.name "github-actions" + git config user.email "actions@github.com" + git add QMB/version.txt QMB/PacletInfo.wl + git commit -m "chore: bump version to ${{ steps.bump.outputs.new }}" + git push + + - name: Create tag + run: | + git tag v${{ steps.bump.outputs.new }} + git push origin v${{ steps.bump.outputs.new }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.bump.outputs.new }} + generate_release_notes: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..39e03d9 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,18 @@ +name: Run Tests + +on: + push: + branches: [develop, main] + pull_request: + branches: [develop, main] + +jobs: + test: + name: Run Tests + runs-on: self-hosted + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Run test suite + run: wolframscript -file tests/RunAllTests.wl diff --git a/QMB/Tests/InitTests.wl b/QMB/Tests/InitTests.wl index 9130c6a..329b54d 100644 --- a/QMB/Tests/InitTests.wl +++ b/QMB/Tests/InitTests.wl @@ -35,7 +35,7 @@ VerifyTest[ data = Import[PacletPath]; Version /. List @@ data ], - "2.4.1", + "2.4.2", "Local version reads correctly from PacletInfo.wl" ] @@ -93,13 +93,13 @@ TestSection["Step 4 \[LongDash] Version comparison"] Print[" Checking =!= detects mismatch..."]; VerifyProperty[ - ("2.4.1" =!= "2.4.0"), + ("2.4.2" =!= "2.4.0"), "=!= correctly detects version mismatch" ] Print[" Checking =!= detects match..."]; VerifyProperty[ - !("2.4.1" =!= "2.4.1"), + !("2.4.2" =!= "2.4.2"), "=!= correctly detects matching versions" ] diff --git a/QMB/prueba.txt b/QMB/prueba.txt deleted file mode 100644 index 400811c..0000000 --- a/QMB/prueba.txt +++ /dev/null @@ -1 +0,0 @@ -dfjasdlkj diff --git a/tests/RunAllTests.wl b/tests/RunAllTests.wl new file mode 100644 index 0000000..1ac5d2a --- /dev/null +++ b/tests/RunAllTests.wl @@ -0,0 +1,43 @@ +(* ::Package:: *) + +(* ============================================================ + RunAllTests.wl + Discovers and runs all *Tests.wl files in the repo. + Usage: wolframscript -file tests/RunAllTests.wl + ============================================================ *) + +Get[FileNameJoin[{DirectoryName[$InputFileName], + "..", "QMB", "Tests", "TestUtils.wl"}]] + +Print["============================================================"]; +Print["libs Test Suite"]; +Print["============================================================"]; + +(* Busca todos los *Tests.wl en el repo, excluyendo TestUtils.wl *) +testFiles = Select[ + FileNames[ + "*Tests.wl", + DirectoryName[DirectoryName[$InputFileName]], + Infinity + ], + !StringContainsQ[#, "TestUtils"] && + !StringContainsQ[#, "RunAllTests"] & +]; + +If[Length[testFiles] === 0, + Print["No test files found."]; + Quit[] +]; + +Print["Found ", Length[testFiles], " test file(s):"]; +Scan[Print[" ", FileNameTake[#]] &, testFiles]; + +Scan[ + Function[file, + Print["\n>>> Running: ", FileNameTake[file]]; + Get[file] + ], + testFiles +]; + +PrintTestSummary[]