From 37d22d52ea0fc677614ac0c048abb60403eba6ca Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Tue, 21 May 2024 13:47:23 +0200 Subject: [PATCH 01/15] Add package description Closes #3 --- dylan-package.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 dylan-package.json diff --git a/dylan-package.json b/dylan-package.json new file mode 100644 index 0000000..2a1c806 --- /dev/null +++ b/dylan-package.json @@ -0,0 +1,15 @@ +{ + "dependencies": [ ], + "dev-dependencies": [ + "testworks", + "sphinx-extensions" + ], + "description": "Bindings to Zlib library", + "name": "zlib", + "version": "0.1.0", + "url": "https://github.com/dylan-lang/zlib", + "keywords": [ "zlib", "binding" ], + "contact": "dylan-lang@google.com", + "license": "MIT", + "license-url": "https://opensource.org/license/mit" +} From d29b94d00cf7b8035ee4404403f5c327b6622b80 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Tue, 21 May 2024 13:47:00 +0200 Subject: [PATCH 02/15] Add .gitignore --- .gitignore | 11 +++++++++++ library.dylan => source/library.dylan | 0 main.dylan => source/main.dylan | 0 zlib.lid => source/zlib.lid | 0 4 files changed, 11 insertions(+) create mode 100644 .gitignore rename library.dylan => source/library.dylan (100%) rename main.dylan => source/main.dylan (100%) rename zlib.lid => source/zlib.lid (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..17d2098 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Development directories + +/_build/ +/_packages/ +/registry/ + +# Backup files + +*~ + +/documentation/build/ \ No newline at end of file diff --git a/library.dylan b/source/library.dylan similarity index 100% rename from library.dylan rename to source/library.dylan diff --git a/main.dylan b/source/main.dylan similarity index 100% rename from main.dylan rename to source/main.dylan diff --git a/zlib.lid b/source/zlib.lid similarity index 100% rename from zlib.lid rename to source/zlib.lid From 7e4293ea0791ec245dc45316a5a91f6513279a3a Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Tue, 21 May 2024 16:11:40 +0200 Subject: [PATCH 03/15] Rename main.dylan to zlib.dylan --- source/{main.dylan => zlib.dylan} | 0 source/zlib.lid | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename source/{main.dylan => zlib.dylan} (100%) diff --git a/source/main.dylan b/source/zlib.dylan similarity index 100% rename from source/main.dylan rename to source/zlib.dylan diff --git a/source/zlib.lid b/source/zlib.lid index c659072..9cac112 100644 --- a/source/zlib.lid +++ b/source/zlib.lid @@ -2,4 +2,4 @@ library: zlib executable: zlib c-libraries: -lz files: library - main + zlib From 2103a0518e54a75622d4c0c6d8923c80da109fc8 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Tue, 21 May 2024 16:33:02 +0200 Subject: [PATCH 04/15] Split zlib module from zlib module implementation --- source/library.dylan | 17 +++++++++++++++-- source/zlib.dylan | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source/library.dylan b/source/library.dylan index bad31a2..1a66ecf 100644 --- a/source/library.dylan +++ b/source/library.dylan @@ -3,11 +3,24 @@ module: dylan-user define library zlib use common-dylan; use c-ffi; - export zlib; + + export + zlib, + zlib-impl; end library; define module zlib + create + compress; +end module; + +define module zlib-impl use common-dylan; use c-ffi; - export compress; + + use zlib; + + export + zlib-compress, + zlib-compress-bound; end module; diff --git a/source/zlib.dylan b/source/zlib.dylan index 2a969fb..3d10617 100644 --- a/source/zlib.dylan +++ b/source/zlib.dylan @@ -1,4 +1,4 @@ -module: zlib +module: zlib-impl define C-function zlib-compress parameter destination :: ; From 926907b025404d3b96dbd5a935816aa6af620f45 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Tue, 21 May 2024 16:36:57 +0200 Subject: [PATCH 05/15] Remove commented test --- source/zlib.dylan | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/zlib.dylan b/source/zlib.dylan index 3d10617..57030ca 100644 --- a/source/zlib.dylan +++ b/source/zlib.dylan @@ -26,7 +26,3 @@ define function compress (string :: ) result; end if; end; -/* -define variable foobar = "foobar"; -format-out("%= => %=\n", foobar, compress(foobar)); -*/ From 1e3f568d4cbcbdb1ae6e4c10680533bd92f8aa26 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Tue, 21 May 2024 16:54:05 +0200 Subject: [PATCH 06/15] Change library target type Change from executable to DLL --- source/zlib.lid | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/zlib.lid b/source/zlib.lid index 9cac112..806c568 100644 --- a/source/zlib.lid +++ b/source/zlib.lid @@ -1,5 +1,5 @@ -library: zlib -executable: zlib -c-libraries: -lz -files: library +Library: zlib +Target-Type: dll +C-Libraries: -lz +Files: library zlib From 1e85eb2bb0887dbac2dca42a6fefdcbf27887337 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Wed, 22 May 2024 07:56:18 +0200 Subject: [PATCH 07/15] Add tests skeleton Closes #6 --- tests/library.dylan | 16 ++++++++++++++++ tests/zlib-test-suite.dylan | 8 ++++++++ tests/zlib-test-suite.lid | 4 ++++ 3 files changed, 28 insertions(+) create mode 100644 tests/library.dylan create mode 100644 tests/zlib-test-suite.dylan create mode 100644 tests/zlib-test-suite.lid diff --git a/tests/library.dylan b/tests/library.dylan new file mode 100644 index 0000000..7ed6223 --- /dev/null +++ b/tests/library.dylan @@ -0,0 +1,16 @@ +Module: dylan-user + +define library zlib-test-suite + use common-dylan; + use testworks; + use io; + use zlib; +end library; + +define module zlib-test-suite + use common-dylan; + use testworks; + use format-out; + use zlib; + use zlib-impl; +end module; diff --git a/tests/zlib-test-suite.dylan b/tests/zlib-test-suite.dylan new file mode 100644 index 0000000..0f6a733 --- /dev/null +++ b/tests/zlib-test-suite.dylan @@ -0,0 +1,8 @@ +Module: zlib-test-suite + +define test compress-test () + let compressed = compress("Hello"); +end test; + +// Use `_build/bin/hello-world-test-suite --help` to see options. +run-test-application() diff --git a/tests/zlib-test-suite.lid b/tests/zlib-test-suite.lid new file mode 100644 index 0000000..0359bfb --- /dev/null +++ b/tests/zlib-test-suite.lid @@ -0,0 +1,4 @@ +Library: zlib-test-suite +Files: library.dylan + zlib-test-suite +Target-Type: executable From fe20cebdf151faa5ea24368c6c42a26218a0dfd5 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Wed, 22 May 2024 08:53:43 +0200 Subject: [PATCH 08/15] Add initial documentation --- documentation/Makefile | 20 +++++++++++++++++ documentation/make.bat | 35 ++++++++++++++++++++++++++++++ documentation/source/conf.py | 33 ++++++++++++++++++++++++++++ documentation/source/index.rst | 17 +++++++++++++++ documentation/source/reference.rst | 33 ++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 documentation/Makefile create mode 100644 documentation/make.bat create mode 100644 documentation/source/conf.py create mode 100644 documentation/source/index.rst create mode 100644 documentation/source/reference.rst diff --git a/documentation/Makefile b/documentation/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/documentation/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/documentation/make.bat b/documentation/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/documentation/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/documentation/source/conf.py b/documentation/source/conf.py new file mode 100644 index 0000000..5b4268c --- /dev/null +++ b/documentation/source/conf.py @@ -0,0 +1,33 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +import sys, os +sys.path.insert(0, os.path.abspath('../../_packages/sphinx-extensions/current/src/sphinxcontrib')) + +import dylan.themes as dylan_themes +extensions = ['dylan.domain'] + +templates_path = ['_templates'] +exclude_patterns = [] + +primary_domain = 'dylan' + + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +project = 'Zlib' +copyright = '2024, Dylan Hackers' +author = 'Dylan Hackers' +release = '0.1.0' + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'furo' +html_static_path = ['_static'] diff --git a/documentation/source/index.rst b/documentation/source/index.rst new file mode 100644 index 0000000..75057f3 --- /dev/null +++ b/documentation/source/index.rst @@ -0,0 +1,17 @@ +Welcome to Zlib's documentation! +================================ + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + :hidden: + + reference + +This is the beginning of a binding to the `Zlib +`_ library. + +Indices and tables +================== + +* :ref:`genindex` diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst new file mode 100644 index 0000000..8c2ece7 --- /dev/null +++ b/documentation/source/reference.rst @@ -0,0 +1,33 @@ +Reference +========= + +.. current-library:: zlib +.. current-module:: zlib + +Utility functions +----------------- + +This functions are implemented on top of the basic zlib +stream-oriented functions. To simplify the interface, some default +options are assumed (compression level and memory usage). + + +.. function:: compress + + Compress a string. + + :signature: compress *string* => (compressed-string) + + :parameter string: String to compress. An instance of :drm:`` + :value compressed-string: An instance of :drm:`` + + :description: + + Compress the source string into a new string. If there is a problem + in the compression process it raises an error. + + :example: + + .. code-block:: dylan + + let compressed = compress("Hello"); From 1a635023fef430d7897ab3a3bc2e11e5f00e018a Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Wed, 22 May 2024 09:33:39 +0200 Subject: [PATCH 09/15] Add LICENSE Fix #2 --- LICENSE | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f8765d8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright 2024 dylan-hackers + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +“Software”), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From b43df383ada12352231a1bda54c5de374dd1e886 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Wed, 22 May 2024 09:43:35 +0200 Subject: [PATCH 10/15] Add README Fix #1 --- README.rst | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..090b924 --- /dev/null +++ b/README.rst @@ -0,0 +1,31 @@ +Zlib +==== + +Opendylan binding around Zlib library. + +Building +-------- + +Install development libraries + +.. code-block:: console + + $ sudo apt install zlib1g-dev + +Download dependencies: + +.. code-block:: console + + $ dylan update + +Build: + +.. code-block:: console + + $ dylan build --all + +Run tests: + +.. code-block:: console + + $ _build/bin/zlib-test-suite From 0c9f9ebeabeba93f5ef9cc9568540334b1fa040c Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Wed, 29 May 2024 07:50:46 +0200 Subject: [PATCH 11/15] Add dependabot --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0d08e26 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From d0785ae2add42bebc8b24da51ece9581f9603daa Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Wed, 29 May 2024 07:53:23 +0200 Subject: [PATCH 12/15] Add CI tests Close #6 --- .github/workflows/build-and-test.yml | 38 ++++++++++++++++++++++++++++ tests/zlib-test-suite.dylan | 4 ++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..d7fd321 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,38 @@ +name: Build and test + +on: + push: + # all branches + pull_request: + # all branches + + # This enables the Run Workflow button on the Actions tab. + workflow_dispatch: + +jobs: + build-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Opendylan + uses: dylan-lang/install-opendylan@v3 + + - name: Add zlib dev dependency + run: sudo apt-get install -y zlib1g-dev + + - name: Download dependencies + run: dylan update + + - name: Build tests + run: dylan build zlib-test-suite + + - name: Run tests + run: _build/bin/zlib-test-suite --progress none --report surefire > _build/TEST-zlib.xml + + - name: Publish Test Report + if: success() || failure() + uses: mikepenz/action-junit-report@v4 + with: + report_paths: '**/_build/TEST-*.xml' diff --git a/tests/zlib-test-suite.dylan b/tests/zlib-test-suite.dylan index 0f6a733..86e4932 100644 --- a/tests/zlib-test-suite.dylan +++ b/tests/zlib-test-suite.dylan @@ -1,7 +1,9 @@ Module: zlib-test-suite define test compress-test () - let compressed = compress("Hello"); + // stupid test until uncompress is working + let compressed = compress("A horse, a horse, my kingdom for a horse"); + expect-equal(30, compressed.size); end test; // Use `_build/bin/hello-world-test-suite --help` to see options. From 4922acfa13560d280c374ce68ed436b8fe4cc6ef Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Wed, 29 May 2024 08:25:51 +0200 Subject: [PATCH 13/15] Build and deploy documentation to GH pages Close #7 --- .github/workflows/build-docs.yml | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/build-docs.yml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 0000000..0e37f67 --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,56 @@ +name: Build and deploy documentation + +on: + push: + # all branches + paths: + - 'documentation/**' + + # This enables the Run Workflow button on the Actions tab. + workflow_dispatch: + +# https://github.com/JamesIves/github-pages-deploy-action#readme +permissions: + contents: write + +# Set DYLAN environment variable to GITHUB_WORKSPACE so packages are +# installed in ../../_packages relative to documentation's Makefile +env: + DYLAN: ${{ github.workspace }} + +jobs: + + build-and-deploy: + runs-on: ubuntu-latest + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Check links + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/fraya/dylan-docs + options: -v ${{ github.workspace }}/documentation:/docs + run: make linkcheck + + - name: Build docs with Furo theme + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/fraya/dylan-docs + options: -v ${{ github.workspace }}/documentation:/docs + run: make html + + - name: Upload html artifact + uses: actions/upload-artifact@v4 + with: + name: zlib-doc-html + path: documentation/build/html/ + + - name: Bypassing Jekyll on GH Pages + run: sudo touch documentation/build/html/.nojekyll + + - name: Deploy documents to GH pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: documentation/build/html From fa6a6585631d898ffa3cd5e80837463eedcd6ea9 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Thu, 30 May 2024 08:44:38 +0200 Subject: [PATCH 14/15] doc: Replace determiner 'this' for 'these' Use 'these' with plural nouns. --- documentation/source/reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/source/reference.rst b/documentation/source/reference.rst index 8c2ece7..471c98a 100644 --- a/documentation/source/reference.rst +++ b/documentation/source/reference.rst @@ -7,7 +7,7 @@ Reference Utility functions ----------------- -This functions are implemented on top of the basic zlib +These functions are implemented on top of the basic zlib stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage). From e672849af3ba8e41a8c52352ba76e2031bc1f1a9 Mon Sep 17 00:00:00 2001 From: Fernando Raya Date: Thu, 30 May 2024 08:47:32 +0200 Subject: [PATCH 15/15] Remove file extension in .lid Don't mix files with extension and files without it. --- tests/zlib-test-suite.lid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/zlib-test-suite.lid b/tests/zlib-test-suite.lid index 0359bfb..7d6af49 100644 --- a/tests/zlib-test-suite.lid +++ b/tests/zlib-test-suite.lid @@ -1,4 +1,4 @@ Library: zlib-test-suite -Files: library.dylan +Files: library zlib-test-suite Target-Type: executable