Skip to content
Open
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
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Tests

on: [push, pull_request]

permissions:
contents: read

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: actions/setup-node@v4
with:
node-version: "22"
- run: python -m unittest discover -s tests -v
8 changes: 8 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ The workflow uses [npm trusted publishing](https://docs.npmjs.com/trusted-publis
`devin-cli`, workflow `publish-npm.yml` (no environment) as its trusted
publisher.

## Tests

With Python and npm on `PATH`, run the packaging tests without publishing:

```sh
python -m unittest discover -s tests -v
```

## GitHub releases

`scripts/release_from_manifest.py` (run hourly by
Expand Down
2 changes: 1 addition & 1 deletion scripts/publish_npm.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def build_launcher_package(version: str, out: Path) -> Path:


def npm(args: list[str], cwd: Path) -> None:
subprocess.run(["npm", *args], cwd=cwd, check=True)
subprocess.run([shutil.which("npm") or "npm", *args], cwd=cwd, check=True)


def release(pkg_dir: Path, tag: str, registry: str, publish: bool, provenance: bool) -> None:
Expand Down
29 changes: 29 additions & 0 deletions tests/test_publish_npm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import json
import tarfile
import tempfile
import unittest
from pathlib import Path

from scripts.publish_npm import release


class NpmPackagingTests(unittest.TestCase):
def test_pack_from_directory_with_spaces(self):
with tempfile.TemporaryDirectory(prefix="devin npm test ") as tmp:
out = Path(tmp)
pkg_dir = out / "launcher package"
pkg_dir.mkdir()
package = {"name": "devin-pack-test", "version": "1.0.0", "private": True}
(pkg_dir / "package.json").write_text(json.dumps(package), encoding="utf-8")

release(pkg_dir, "latest", "https://registry.npmjs.org/", publish=False, provenance=False)

archive = out / "devin-pack-test-1.0.0.tgz"
self.assertTrue(archive.is_file())
with tarfile.open(archive) as tf:
with tf.extractfile("package/package.json") as metadata:
self.assertEqual(json.load(metadata), package)


if __name__ == "__main__":
unittest.main()