Skip to content

Commit

Permalink
feat: add docker
Browse files Browse the repository at this point in the history
adjust CI for docker use
  • Loading branch information
duncdrum committed Apr 10, 2024
1 parent 239667f commit fa970ba
Show file tree
Hide file tree
Showing 11 changed files with 16,183 additions and 8,285 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "chore(gha):"
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "03:00"
commit-message:
prefix: "chore(npm):"
106 changes: 106 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This workflow builds a xar archive, deploys it into exist and execute a simple smoke test.
# It also includes code for using semantic-release to upload packages as part of GitHub releases
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# For node free automated release see https://trstringer.com/github-actions-create-release-upload-artifacts/

name: exist-db CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# 7.0.0-SNAPSHOT and 6.2.1 created
exist-version: [latest, release]
java-version: [11, 17]
exclude:
- exist-version: release
java-version: 17
- exist-version: latest
java-version: 11

steps:
# Checkout code
- uses: actions/checkout@v4
- name: Install Test Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxml2-utils bats
# sanity check
# TODO(DP) Validate ?
- name: Ensure all XML files are well-formed
run: |
xmllint --noout \
$(find . -type f -name '*.xml')
# Build
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: lts/*

- name: Build Expath Package
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.java-version }}
- run: -Dapp.version=1.0.0-SNAPSHOT

- name: Add expath dependencies
working-directory: build
run: |
wget https://exist-db.org/exist/apps/public-repo/public/expath-crypto-module-6.0.1.xar -O 000.xar
wget http://exist-db.org/exist/apps/public-repo/public/templating-1.1.0.xar -O 001.xar
wget https://exist-db.org/exist/apps/public-repo/public/tei-publisher-lib-2.10.1.xar -O 002.xar
# Install
- name: Start exist-ci containers
run: |
docker run -dit -p 8080:8080 -v ${{ github.workspace }}/build:/exist/autodeploy \
--name exist --rm --health-interval=2s --health-start-period=4s \
duncdrum/existdb:${{ matrix.exist-version }}
- name: wait for install to finish
timeout-minutes: 30
run: |
while ! docker logs exist | grep -q "Server has started"; \
do sleep 2s; \
done
# Test
- name: Run smoke test
run: bats --tap test/*.bats

# TODO: add xq tests

# Lint commit messages
- name: lint commit message
uses: wagoid/commitlint-github-action@v5

release:
name: Release
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version: lts/*
- name: Install dependencies
run: npm ci --no-optional
- name: Perform Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLIC_REPO: ${{ secrets.PUBLIC_REPO }}
run: npx semantic-release
# TODO(DP):
# - add secrets to github
# - publish to public repo?
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ build.properties.local.xml
!.npmrc
!.nvmrc
!.gitkeep
!.github/
!.releaserc
43 changes: 43 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"branches": [
"master"
],
"plugins": [
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
},
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
},
[
"@semantic-release/exec",
{
"prepareCmd": "ant -Dapp.version=${nextRelease.version}"
}
],
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
"assets": [
{
"path": "build/hsg-shell.xar",
"name": "hsg-shell.xar",
"label": "Expath package (hsg-shell.xar)"
}
]
}
]
]
}
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@ You need to have *ant*, *git*, *nvm* and *nodeJS* installed.
Install [nvm](https://github.com/nvm-sh/nvm) and follow the [installation instructions](https://github.com/nvm-sh/nvm#installing-and-updating).
2. Make sure to install nvm with a specific node version (see https://github.com/nvm-sh/nvm/blob/master/README.md#usage)

nvm install 14.19.3
`nvm install 18.18.2`

3. If you have already used nvm before and have various node versions already installed, you can skip 1). Now just make sure to use the project's required node version by running

nvm use
`nvm use 18`

This command will check the local node settings in the project's `.nvmrc` file and switch to this node version only for this project.

4. Install (or update to) the latest `npm` version with:

npm install -g npm
`npm install -g npm`

5. Install bower:
5. Install gulp

npm install -g bower

6. Install gulp

npm install -g gulp
`npm install -g gulp`

The project's gulp file depends on `gulp 4` (or higher) syntax, so make sure in the next step, that you'll have gulp 4.x running.

Expand All @@ -55,9 +51,9 @@ A new `package-lock.json` file will be created, which should be added to version
* `ant node` will install the appropriate node version for this project, which is specified in the `.nvmrc` file, currently `v14.19.3`.
* `ant` will build a XAR file after automatically running npm install bower install and gulp (build).

1. Install the package `build/hsg-shell-x.y.z.xar` with the Package Manager
2. Install the package `build/hsg-shell.xar` with the Package Manager

1. Click on the *history.state.gov* icon on the eXist Dashboard
3. Click on the *history.state.gov* icon on the eXist Dashboard

### How to update Node and other build & development tools

Expand Down Expand Up @@ -221,3 +217,18 @@ Have a look at the documentation:
* Webdriver.io functions: [webdriver.io/docs/api](https://webdriver.io/docs/api.html)
* List of all functions in the Chai Assertion library: [chaijs.com/api/assert](https://www.chaijs.com/api/assert/)
* Overview about mocha.js: [mochajs.org](https://mochajs.org/)
## Release
Releases for this data package are automated. Any commit to the `master` branch will trigger the release automation.
All commit message must conform to [Conventional Commit Messages](https://www.conventionalcommits.org/en/v1.0.0/) to determine semantic versioning of releases, please adhere to these conventions, like so:
| Commit message | Release type |
|-----------------|--------------|
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| `perf(pencil): remove graphiteWidth option`<br/><br/>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br/>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release |
When opening PRs commit messages are checked using commitlint.
3 changes: 2 additions & 1 deletion build.properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<name>hsg-shell</name>
<url>http://history.state.gov/ns/site/hsg</url>
<title>history.state.gov 3.0 shell</title>
<version>3.0.1</version>
<!-- VERSION SET AUTOMATICALLY DO NOT CHANGE -->
<!-- <version>3.0.1</version> -->
</app>
<npm>@npm@</npm>
<gulp>@gulp@</gulp>
Expand Down
5 changes: 4 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<echo message="Creating xar file..."/>
<echo message="------------------------------------------------------------"/>

<zip basedir="${basedir}" destfile="${build.dir}/${app.name}-${app.version}.xar">
<zip basedir="${basedir}" destfile="${build.dir}/${app.name}.xar">
<!-- <exclude name="app/**"/> -->
<exclude name="${build.dir}/**"/>
<exclude name="*.tmpl"/>
Expand All @@ -95,6 +95,9 @@
<exclude name="build.properties.local.xml"/>
<exclude name="local.node-exist.json"/>
<exclude name="wdio*"/>
<exclude name=".github/**"/>
<exclude name=".releaserc"/>
<exclude name="commitlint.config.cjs"/>
</zip>
</target>

Expand Down
6 changes: 6 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [1, 'always', 200]
}
}
Loading

0 comments on commit fa970ba

Please sign in to comment.