Skip to content

Commit

Permalink
Import current state
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanruth committed Nov 8, 2024
0 parents commit 2f80f72
Show file tree
Hide file tree
Showing 9 changed files with 475 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Test the Install Action
on:
push:
jobs:

test-unix:
if: false # TEMPORARILY DISABLED
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest # intel
- ubuntu-24.04 # intel
- ubuntu-22.04 # intel
- ubuntu-20.04 # intel
- macos-12 # intel
- macos-13 # intel
- macos-14 # arm
- macos-15 # arm
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:

- uses: actions/checkout@v4

- name: Run this action
id: thisaction
uses: ./.

- name: create .monetdb
run: |
echo user=monetdb >> $HOME/.monetdb
echo password=monetdb >> $HOME/.monetdb
- run: uname -a; echo; id

- name: check outputs
run: |
ls "${{ steps.thisaction.outputs.bindir }}/mclient"
ls "${{ steps.thisaction.outputs.includedir }}/monetdb/monetdbe.h"
ls "${{ steps.thisaction.outputs.libdir }}/libmonetdbe.${{ steps.thisaction.outputs.dynsuffix }}"
- run: mclient --version

- run: mclient -L- -d demo -s 'select * from environment'


test-windows:
runs-on: windows-latest
timeout-minutes: 5
steps:

- uses: actions/checkout@v4

- name: Run this action
id: thisaction
uses: ./.

- run: |
ls "C:/Program Files/MonetDB/MonetDB5"
ls "C:/Program Files/MonetDB/MonetDB5/bin"
shell: pwsh
- name: check output parameters
run: |
ls "${{ steps.thisaction.outputs.bindir }}/mclient.bat"
ls "${{ steps.thisaction.outputs.includedir }}/monetdb/monetdbe.h"
ls "${{ steps.thisaction.outputs.libdir }}/monetdbe.${{ steps.thisaction.outputs.dynsuffix }}"
- run: |
mclient --version
shell: cmd
- name: Check tcp
run: python3 tryconnect.py
shell: pwsh

- run: netstat -n -a -b -o
shell: cmd

- run: |
mclient -L- -d monetdb://127.0.0.1/demo -s 'select * from environment'
shell: cmd
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Joeri van Ruth

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.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
A GitHub Action to install MonetDB
==================================

> **NOTE** This Action is in its early stages.
>
> This document describes the way it is intended to work, not how it currently
> works. Right now, only binary installs work, nothing is configurable and no
> server is started on Windows.

This [GitHub Action] installs [MonetDB].
It can be used to test projects that interact with MonetDB.
For example,

```
run_mclient:
runs-on: ubuntu-latest
steps:
- uses: MonetDB/install-monetdb@v1
- run: mclient -d demo 'SELECT * FROM environment'
```

The step `uses: MonetDB/install-monetdb@v1` takes care of
1. Installing MonetDB and putting it on the PATH
2. Creating a database 'demo'
3. Starting the server
4. Creating a '.monetdb' file with user=monetdb and password=monetdb

It works on Linux, MacOS and Windows runners. It installs binary packages unless
configured to build from source.
* On Linux, it installs .deb packages downloaded from [monetdb.org][MonetDB].
* On Windows, it uses .msi installers from [monetdb.org][MonetDB].
* On MacOS, in installs MonetDB from [Homebrew].

When building from source, it can build from a pre-downloaded source tree or it
can check out code from MonetDB's Mercurial repository or its GitHub mirror.


Inputs
------

If no parameters are specified, this Action installs the latest binary packages.
If **version** is specified, it tries to install that specific version of the
binaries. If **source** is specified, it tries to compile the sources found in
that directory. If **rev** is specified, it tries to check out the given
revision from MonetDB's GitHub repository, or from whatever repository is
configured through **hg_repo** or **git_repo**.

* **version**: The version number, written either numerically (11.51.5) or as
name (Aug2024-SP1 or Aug2024_SP1). The default is to install the latest
version. Cannot be used together with **source** or **rev**.

* **source**: Path to the MonetDB source tree. If specified, MonetDB will be
built from these sources. This action will try to install build dependencies
such as cmake. No default. Cannot be used together with **version** or **rev**.

* **prefix**: Directory prefix to install the binaries in. Defaults to
`/usr/local` on Linux and MacOS, `C:\Program Files\MonetDB\MonetDB5` on
Windows. Ignored when installing binary packages on Linux and MacOS.

* **rev**: Revision to check out from **git_repo** or **hg_repo**. No default.
Cannot be used together with **version** or **source**.

Uses the GitHub mirror rather than the primary Mercurial repository when
neither **git_repo** nor **hg_repo** is given. This is because GitHub Action
runners tend to have truly excellent network connectivity to GitHub. However,
if you wish to compile bleeding edge sources make sure to specify **hg_repo**
because the GitHub mirror may lag slightly behind.

* **hg_repo**: Mercurial repo to clone from when **rev** is given.
Defaults to `https://dev.monetdb.org/hg/MonetDB/`.

* **git_repo**: Git repository to clone from when **rev** is given
and **hg_repo** is not.


Outputs
-------

* **bindir**: Directory where executables have been installed. Will contain for
example `mclient` or `mclient.exe` on Windows.

* **libdir**: Directory where libraries have been installed. Will contain for
example `libmonetdbe.so`, `libmonetdbe.dylib` or `monetdbe.dll`.

* **includedir**: Directory where header files have been installed. Will contain
for example `monetdb/monetdb_config.h`.


Example
-------

TODO



[MonetDB]: https://monetdb.org/
[GitHub Action]: https://github.com/features/actions
[Homebrew]: https://brew.sh/
39 changes: 39 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
TODO
====

The end goal is to create GitHub Action that installs MonetDB for use
in tests of other components. For example, pymonetdb.

The plan is to install a binary distribution from monetdb.org, not build
it from source. This is quicker and provides 'official' binaries.

It should support

- Linux (x86_64)
- Windows (x86_64)
- MacOS through Homebrew (arm64 and x86_64)

After running the action.

- MonetDB should be installed and on the path
- monetbd should be running and a database 'demo' should exist


Future work
===========

Picking a specific version. For binary installs this depends on what's still
available at monetdb.org.

Source installs


Steps
=====

1. Create an embeddable workflow that installs MonetDB on Ubuntu, and a workflow
that tests it.

2. MacOS

3. Outputs: bindir, libdir, includedir
86 changes: 86 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Install MonetDB
description: Install MonetDB and make it ready for use
outputs:
bindir:
description: where binaries are installed
value: ${{ steps.set_output.outputs.bindir }}
includedir:
description: where include files are installed
value: ${{ steps.set_output.outputs.includedir }}
libdir:
description: where libraries are installed
value: ${{ steps.set_output.outputs.libdir }}
dynsuffix:
description: "the suffix of a shared library: so, dylib or dll"
value: ${{ steps.set_output.outputs.dynsuffix }}

runs:
using: "composite"
steps:

- name: Linux Package Install
if: runner.os == 'Linux'
run: ${{ github.action_path }}/install-linux-bin.sh
shell: bash

- name: MacOS Homebrew Install
if: runner.os == 'macOS'
run: ${{ github.action_path }}/install-macos-bin.sh
shell: bash

- name: Find Windows MSI files
id: findmsi
if: runner.os == 'Windows'
# this script outputs main_msi=URL and odbc_msi=URL
run: python3 ${{ github.action_path }}\find-msi.py >>$env:GITHUB_OUTPUT
shell: pwsh

- name: Windows MSI Install
if: runner.os == 'Windows'
run: |
$main_msi="c:\monetdb.msi"
$main_url="${{ steps.findmsi.outputs.main_msi }}"
Write-Output "Download and install '$main_msi' from '$main_url'"
(New-Object System.Net.WebClient).DownloadFile("$main_url","$main_msi");
$procMain = Start-Process "$main_msi" -ArgumentList '/quiet /passive /qn /norestart INSTALLLEVEL=1000 MSIRMSHUTDOWN=2' -Wait
#
$odbc_msi="c:\monetdb-odbc.msi"
$odbc_url="${{ steps.findmsi.outputs.odbc_msi }}"
Write-Output "Download and install '$odbc_msi' from '$odbc_url'"
(New-Object System.Net.WebClient).DownloadFile("$odbc_url","$odbc_msi");
$procMain = Start-Process "$odbc_msi" -ArgumentList '/quiet /passive /qn /norestart INSTALLLEVEL=1000 MSIRMSHUTDOWN=2' -Wait
shell: pwsh

- name: Make sure embedded Python remains disabled
if: runner.os == 'Windows'
run: del "C:\Program Files\MonetDB\MonetDB5\pyapi_locatepython3.bat"
shell: cmd

- name: Set output parameters
if: runner.os == 'Windows'
run: |
Add-Content github.output "bindir=C:\Program Files\MonetDB\MonetDB5"
Add-Content github.output "includedir=C:\Program Files/MonetDB/MonetDB5/include"
Add-Content github.output "libdir=C:\Program Files\MonetDB\MonetDB5\bin"
Add-Content github.output "dynsuffix=dll"
cat github.output
shell: pwsh

- name: Update PATH
if: runner.os == 'Windows'
run: |
Add-Content $env:GITHUB_PATH "C:\Program Files\MonetDB\MonetDB5"
shell: pwsh

- name: Start the server
if: runner.os == 'Windows'
run: |
Start-Process -FilePath "C:\Program Files\MonetDB\MonetDB5\MSQLserver.bat" -NoNewWindow -ArgumentList "--set","embedded_py=false"
shell: pwsh

- name: Communicate bindir, libdir, includedir and dynsuffix
id: set_output
run: |
cat github.output # should have been generated by install-*-bin.sh
cat github.output >>$GITHUB_OUTPUT
shell: bash
Loading

0 comments on commit 2f80f72

Please sign in to comment.