diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 37395dbaf3..be1784a237 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -176,9 +176,9 @@ jobs: env: image_cache: ghcr.io/simplex-chat/simplex-chat-build-cache:${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }} source_hashes: dist-newstyle/sources.sha256 - concurrency: + concurrency: &linux-concurrency group: ${{ github.workflow }}-${{ github.ref }}-linux-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ghc }}-${{ needs.maybe-release.outputs.libs_tag }} - cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') && !needs.maybe-release.outputs.libs_tag }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} strategy: fail-fast: false matrix: @@ -205,22 +205,7 @@ jobs: should_run: true ghc: ${{ needs.variables.outputs.GHC_VER }} hash: 'sha256:98ff7968124952e719a8a69bb3cccdd217f5fe758108ac4f21ad22e1df44d237' - - os: 22.04 - os_underscore: 22_04 - arch: aarch64 - runner: "ubuntu-22.04-arm" - should_run: true - ghc: ${{ needs.variables.outputs.GHC_VER }} - hash: 'sha256:6a62a4157b8775eaf4959cb629e757d32d39d1f4c8ac1b0ddc2510b555cf72f3' - libs: true - - os: 24.04 - os_underscore: 24_04 - arch: aarch64 - runner: "ubuntu-24.04-arm" - should_run: true - ghc: ${{ needs.variables.outputs.GHC_VER }} - hash: 'sha256:68434214381cb38287104e629fe8ee720167dd98cbb36ab1cbbab342515fa6ab' - steps: + steps: &linux-steps - name: Checkout Code if: matrix.should_run == true uses: actions/checkout@v3 @@ -398,7 +383,7 @@ jobs: done strip /out/simplex-chat - # Also for pull requests that change the chat core, for the package tests (packages-pr). + # Also for pull requests that change the chat core, for the package tests. - name: Build library id: build-lib if: matrix.libs && (needs.maybe-release.outputs.libs_tag || (needs.maybe-release.outputs.core_changed && matrix.arch == 'x86_64')) @@ -457,14 +442,6 @@ jobs: !dist-lib/src key: ${{ steps.keys.outputs.dist_lib }}-${{ env.branch }}-${{ github.sha }} - - name: Upload library artifact - if: matrix.libs && needs.maybe-release.outputs.core_changed && matrix.arch == 'x86_64' - uses: actions/upload-artifact@v7 - with: - name: simplex-chat-libs-linux-${{ matrix.arch }} - path: release-libs/simplex-chat-libs-linux-${{ matrix.arch }}.zip - if-no-files-found: error - - name: Upload library if: needs.maybe-release.outputs.libs_tag && matrix.libs uses: softprops/action-gh-release@v2 @@ -612,6 +589,50 @@ jobs: exit 1 fi + - name: Setup Node.js + id: setup-node + if: ${{ !cancelled() && needs.maybe-release.outputs.core_changed && steps.build-lib.outcome == 'success' }} + uses: actions/setup-node@v7 + with: + node-version: 22 + + - name: Setup Python + id: setup-python + if: ${{ !cancelled() && steps.setup-node.outcome == 'success' }} + uses: actions/setup-python@v7 + with: + python-version: "3.12" + + - name: Build simplex-chat (npm) and add-on + id: build-nodejs + if: ${{ !cancelled() && steps.setup-python.outcome == 'success' }} + shell: bash + working-directory: packages/simplex-chat-nodejs + run: | + (cd ../simplex-chat-client/types/typescript && npm install --no-audit --no-fund && npx tsc) + npm install --ignore-scripts --no-save --no-audit --no-fund ../simplex-chat-client/types/typescript + npx --yes node-gyp rebuild + npx tsc && cp src/simplex.* dist + + - name: Test simplex-chat (npm) + id: test-nodejs + if: ${{ !cancelled() && steps.build-nodejs.outcome == 'success' }} + timeout-minutes: 30 + shell: bash + working-directory: packages/simplex-chat-nodejs + env: + SIMPLEX_LIBS_DIR: ${{ github.workspace }}/release-libs/simplex-chat-libs-linux-${{ matrix.arch }}/libs + run: npx jest --forceExit --testNamePattern '^(?!.*use preset servers)' + + - name: Test simplex-chat (PyPI) + if: ${{ !cancelled() && steps.test-nodejs.outcome == 'success' }} + timeout-minutes: 30 + shell: bash + working-directory: packages/simplex-chat-python + run: | + python -m pip install -e ".[test]" + python -m pytest -q + - name: Remove -O2 build directory id: remove-o2 if: env.cache_o0 == 'true' && !cancelled() && steps.build-cli.outcome == 'success' @@ -657,6 +678,40 @@ jobs: !dist-newstyle/src key: ${{ steps.keys.outputs.dist }}-O0-${{ env.branch }}-${{ github.sha }} + build-linux-push: + name: "ubuntu-${{ matrix.os }}-${{ matrix.arch }} (CLI,Desktop), GHC: ${{ matrix.ghc }}" + needs: [maybe-release, variables] + if: github.event_name != 'pull_request' + runs-on: ${{ matrix.runner }} + permissions: + contents: write + packages: write + env: + image_cache: ghcr.io/simplex-chat/simplex-chat-build-cache:${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }} + source_hashes: dist-newstyle/sources.sha256 + cache_o0: false + concurrency: *linux-concurrency + strategy: + fail-fast: false + matrix: + include: + - os: 22.04 + os_underscore: 22_04 + arch: aarch64 + runner: "ubuntu-22.04-arm" + should_run: true + ghc: ${{ needs.variables.outputs.GHC_VER }} + hash: 'sha256:6a62a4157b8775eaf4959cb629e757d32d39d1f4c8ac1b0ddc2510b555cf72f3' + libs: true + - os: 24.04 + os_underscore: 24_04 + arch: aarch64 + runner: "ubuntu-24.04-arm" + should_run: true + ghc: ${{ needs.variables.outputs.GHC_VER }} + hash: 'sha256:68434214381cb38287104e629fe8ee720167dd98cbb36ab1cbbab342515fa6ab' + steps: *linux-steps + # ================================= # Linux PostgreSQL Library Build # ================================= @@ -783,7 +838,7 @@ jobs: runs-on: ${{ matrix.os }} concurrency: group: ${{ github.workflow }}-${{ github.ref }}-macos-${{ matrix.os }}-${{ needs.maybe-release.outputs.libs_tag }} - cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') && !needs.maybe-release.outputs.libs_tag }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} strategy: fail-fast: false matrix: @@ -1082,7 +1137,7 @@ jobs: runs-on: ${{ matrix.os }} concurrency: group: ${{ github.workflow }}-${{ github.ref }}-windows-${{ matrix.os }}-${{ needs.maybe-release.outputs.libs_tag }} - cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') && !needs.maybe-release.outputs.libs_tag }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} strategy: fail-fast: false matrix: @@ -1338,7 +1393,7 @@ jobs: # A new library release is tested with the Node.js and Python packages and updates them in a release PR. packages: - needs: [maybe-release, build-linux, build-linux-postgres, build-macos, build-windows] + needs: [maybe-release, build-linux, build-linux-push, build-linux-postgres, build-macos, build-windows] if: ${{ !cancelled() && needs.maybe-release.outputs.libs_tag }} # the called workflow can't be granted more than its caller, and its publish job needs these permissions: @@ -1348,16 +1403,3 @@ jobs: with: libs_release: ${{ needs.maybe-release.outputs.libs_tag }} secrets: inherit - -# A pull request that changes the chat core is tested with the Node.js and Python packages. - - packages-pr: - needs: [maybe-release, build-linux] - # build-linux uploads the library before its chat tests run - if: ${{ !cancelled() && needs.maybe-release.outputs.core_changed }} - permissions: - contents: read - id-token: write - uses: ./.github/workflows/packages.yml - with: - libs_artifact: true diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 01c2c1be33..2e58fb4d34 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -39,13 +39,9 @@ on: python_version: description: "simplex-chat PyPI version, bumped when needed by default" required: false - # build.yml: a pull request that changes the chat core, or a new library release + # build.yml: a new library release workflow_call: inputs: - libs_artifact: - description: "test with simplex-chat-libs-linux-x86_64 built by the calling run" - type: boolean - default: false libs_release: description: "test with this simplex-chat-libs release" type: string @@ -119,12 +115,11 @@ jobs: EVENT: ${{ github.event_name }} BASE: ${{ github.event.pull_request.base.sha }} RELEASE_MISSING: ${{ steps.release.outputs.missing }} - LIBS_ARTIFACT: ${{ inputs.libs_artifact }} LIBS_RELEASE: ${{ inputs.libs_release }} run: | if [ -n "$BASE" ]; then git fetch -q --depth=1 origin "$BASE"; fi python3 scripts/ci/packages_release.py build-plan --event "$EVENT" --base "$BASE" \ - --release-missing "$RELEASE_MISSING" --libs-artifact "$LIBS_ARTIFACT" --libs-release "$LIBS_RELEASE" >> "$GITHUB_OUTPUT" + --release-missing "$RELEASE_MISSING" --libs-release "$LIBS_RELEASE" >> "$GITHUB_OUTPUT" build: name: "build ${{ matrix.platform }}" @@ -163,13 +158,6 @@ jobs: npx tsc && cp src/simplex.* dist cp build/Release/simplex.node build/simplex-chat-nodejs-${{ matrix.platform }}.node - - name: Download libsimplex of this run - if: needs.addon.outputs.test && inputs.libs_artifact - uses: actions/download-artifact@v8 - with: - name: simplex-chat-libs-${{ matrix.platform }} - path: ${{ runner.temp }}/libsimplex - - name: Download libsimplex release if: needs.addon.outputs.test && inputs.libs_release env: @@ -177,13 +165,13 @@ jobs: run: curl -fsSL --create-dirs -o "$RUNNER_TEMP/libsimplex/simplex-chat-libs-${{ matrix.platform }}.zip" "$URL" - name: Unpack libsimplex - if: needs.addon.outputs.test && (inputs.libs_artifact || inputs.libs_release) + if: needs.addon.outputs.test && inputs.libs_release run: python -m zipfile -e "$RUNNER_TEMP/libsimplex/simplex-chat-libs-${{ matrix.platform }}.zip" "$RUNNER_TEMP/libsimplex" - name: Test simplex-chat (npm) if: needs.addon.outputs.test env: - SIMPLEX_LIBS_DIR: ${{ (inputs.libs_artifact || inputs.libs_release) && format('{0}/libsimplex/libs', runner.temp) || '' }} + SIMPLEX_LIBS_DIR: ${{ inputs.libs_release && format('{0}/libsimplex/libs', runner.temp) || '' }} # A failed test can leave chat controllers running, and jest then waits for them. # Tests on the public preset servers fail in CI when a server is slow to connect. run: npx jest --forceExit --testNamePattern '^(?!.*use preset servers)' diff --git a/scripts/ci/packages_release.py b/scripts/ci/packages_release.py index 488d35bb8c..b13b9cc00d 100644 --- a/scripts/ci/packages_release.py +++ b/scripts/ci/packages_release.py @@ -54,8 +54,6 @@ ADDON_RUNNERS = { "windows-x86_64": "windows-latest", } ADDON_PLATFORMS = list(ADDON_RUNNERS) -# build.yml builds libsimplex of pull requests on this platform only -CORE_TEST_PLATFORM = "linux-x86_64" ADDON_ASSETS = [f"simplex-chat-nodejs-{platform}.node" for platform in ADDON_PLATFORMS] SHA256_HEX = re.compile(r"^[0-9a-f]{64}$") RELEASES_FILE = "releases.toml" @@ -275,12 +273,10 @@ class BuildPlan: def build_plan( - event: str, release_missing: bool, libs_artifact: bool, libs_release: str, core_changed: bool, addon_changed: bool + event: str, release_missing: bool, libs_release: str, core_changed: bool, addon_changed: bool ) -> BuildPlan: """Each package test runs once, against the libsimplex of the change: a pull request that changes the core - is tested by build.yml with its own libsimplex (libs_artifact), a new library release with that release.""" - if libs_artifact: - return BuildPlan([CORE_TEST_PLATFORM], test=True) + is tested by build.yml with its own libsimplex, a new library release with that release.""" if libs_release: return BuildPlan(ADDON_PLATFORMS, test=True) if event == "pull_request": @@ -382,11 +378,10 @@ def changes(base: str) -> None: def print_build_plan(args: argparse.Namespace) -> None: - pull_request = args.event == "pull_request" and not args.libs_artifact + pull_request = args.event == "pull_request" result = build_plan( args.event, release_missing=args.release_missing, - libs_artifact=args.libs_artifact, libs_release=args.libs_release, core_changed=pull_request and changed_since(args.base, CORE_SOURCES), addon_changed=pull_request and changed_since(args.base, ADDON_SOURCES), @@ -637,7 +632,6 @@ def main(argv: list[str]) -> None: build_parser.add_argument("--event", required=True, help="github.event_name") build_parser.add_argument("--base", default="", help="the base commit of a pull request") build_parser.add_argument("--release-missing", type=github_bool, default=False) - build_parser.add_argument("--libs-artifact", type=github_bool, default=False) build_parser.add_argument("--libs-release", default="") prepare_parser = commands.add_parser("prepare") for package in ["nodejs", "types", "python"]: diff --git a/scripts/ci/test_packages_release.py b/scripts/ci/test_packages_release.py index 634260cabc..1838525c74 100644 --- a/scripts/ci/test_packages_release.py +++ b/scripts/ci/test_packages_release.py @@ -205,8 +205,8 @@ class PlanTest(unittest.TestCase): class BuildPlanTest(unittest.TestCase): - def plan(self, event="push", release_missing=False, libs_artifact=False, libs_release="", core=False, addon=False): - return build_plan(event, release_missing, libs_artifact, libs_release, core, addon) + def plan(self, event="push", release_missing=False, libs_release="", core=False, addon=False): + return build_plan(event, release_missing, libs_release, core, addon) def test_push_builds_a_missing_addon_release_and_tests_it(self): self.assertEqual(self.plan(release_missing=True), BuildPlan(ADDON_PLATFORMS, test=True)) @@ -220,11 +220,6 @@ class BuildPlanTest(unittest.TestCase): self.assertEqual(self.plan("pull_request", core=True), BuildPlan([], test=False)) self.assertEqual(self.plan("pull_request", core=True, addon=True), BuildPlan(ADDON_PLATFORMS, test=False)) - def test_libsimplex_of_the_pull_request_is_tested_on_its_platform(self): - self.assertEqual( - self.plan("pull_request", libs_artifact=True, core=True), BuildPlan(["linux-x86_64"], test=True) - ) - def test_new_library_release_is_tested_on_every_platform(self): self.assertEqual(self.plan(libs_release="core-1.0.0.2"), BuildPlan(ADDON_PLATFORMS, test=True))