Skip to content

Commit 4114d77

Browse files
authored
Merge pull request #32 from HistoryAtState/feat-cicd
feat(var): init ci/cd
2 parents b395ab3 + b6a4a06 commit 4114d77

11 files changed

Lines changed: 8036 additions & 4 deletions

File tree

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

.github/workflows/build.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# This workflow builds a xar archive, deploys it into exist and execute a simple smoke test.
2+
# It also includes code for using semantic-release to upload packages as part of GitHub releases
3+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
4+
# For node free automated release see https://trstringer.com/github-actions-create-release-upload-artifacts/
5+
6+
name: exist-db CI
7+
8+
on: [push, pull_request]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
# 7.0.0-SNAPSHOT and 6.2.1 created
17+
exist-version: [latest, release]
18+
java-version: [11, 17]
19+
exclude:
20+
- exist-version: release
21+
java-version: 17
22+
- exist-version: latest
23+
java-version: 11
24+
25+
steps:
26+
# Checkout code
27+
- uses: actions/checkout@v4
28+
- name: Install Test Dependencies
29+
run: |
30+
sudo apt-get update
31+
sudo apt-get install -y libxml2-utils bats
32+
# sanity check
33+
# TODO(DP) Validate ?
34+
- name: Ensure all XML files are well-formed
35+
run: |
36+
xmllint --noout \
37+
$(find . -type f -name '*.xml')
38+
39+
# Build
40+
- name: Build Expath Package
41+
uses: actions/setup-java@v4
42+
with:
43+
distribution: 'temurin'
44+
java-version: ${{ matrix.java-version }}
45+
- run: ant
46+
47+
# Install
48+
- name: Start exist-ci containers
49+
run: |
50+
docker run -dit -p 8080:8080 -v ${{ github.workspace }}/build:/exist/autodeploy \
51+
--name exist --rm --health-interval=2s --health-start-period=4s \
52+
duncdrum/existdb:${{ matrix.exist-version }}
53+
sleep 15s
54+
55+
# Test
56+
- name: Run test
57+
run: bats --tap test/*.bats
58+
59+
# Lint commit messages
60+
- name: lint commit message
61+
uses: wagoid/commitlint-github-action@v5
62+
63+
release:
64+
name: Release
65+
runs-on: ubuntu-latest
66+
needs: build
67+
if: github.ref == 'refs/heads/master'
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
- name: Setup Node.js
72+
uses: actions/setup-node@v4
73+
with:
74+
cache: npm
75+
node-version: lts/*
76+
- name: Install dependencies
77+
run: npm ci --no-optional
78+
- name: Perform Release
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
PUBLIC_REPO: ${{ secrets.PUBLIC_REPO }}
82+
run: npx semantic-release
83+
# TODO(DP):
84+
# - add secrets to github
85+
# - publish to public repo?

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ build/*
22
.idea/*
33
.existdb.json
44
.DS_Store
5+
expath-pkg.xml
6+
repo.xml
7+
.vscode/
8+
.idea/
9+
node_modules/

.releaserc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
["@semantic-release/exec", {
7+
"prepareCmd": "ant -Dapp.version=${nextRelease.version}"
8+
}],
9+
["@semantic-release/git", {
10+
"assets": ["package.json", "package-lock.json"],
11+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
12+
}],
13+
["@semantic-release/github", {
14+
"assets": [
15+
{
16+
"path": "build/pocom-*.xar",
17+
"name": "pocom-${nextRelease.version}.xar",
18+
"label": "Expath package (pocom-${nextRelease.version}.xar)"
19+
}
20+
]
21+
}]
22+
]
23+
}

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
# Principal Officers & Chiefs of Mission
22

3-
Source data for [Principal Officers & Chiefs of Mission](http://history.state.gov/departmenthistory/people/principals-chiefs).
3+
[![exist-db CI](https://github.com/HistoryAtState/pocom/actions/workflows/build.yml/badge.svg)](https://github.com/HistoryAtState/pocom/actions/workflows/build.yml)
4+
5+
Source data for [Principal Officers & Chiefs of Mission](http://history.state.gov/departmenthistory/people/principals-chiefs).
46

57
## Build
68

79
1. Single `xar` file: Files `articles.xconf` and `issues.xconf` will only contain the index, no triggers!
10+
811
```shell
912
ant
10-
```
13+
```
14+
15+
1. Since Releases have been automated when building locally you might want to supply your own version number (e.g. `X.X.X`) like this:
16+
17+
```shell
18+
ant -Dapp.version=X.X.X
19+
```
20+
21+
## Release
22+
23+
Releases for this data package are automated. Any commit to the `master` branch will trigger the release automation.
24+
25+
All commit message must conform to [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) to determine semantic versioning of releases, please adhere to these conventions, like so:
26+
27+
| Commit message | Release type |
28+
|-----------------|--------------|
29+
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
30+
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
31+
| `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 |
32+
33+
When opening PRs commit messages are checked using commitlint.

build.properties.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<name>pocom</name>
55
<url>http://history.state.gov/ns/data/pocom</url>
66
<title>Principal Officers &amp; Chiefs of Mission (data)</title>
7-
<version>0.5</version>
7+
<!-- VERSION SET AUTOMATICALLY DO NOT CHANGE -->
8+
<!-- <version>0.5.0</version> -->
89
</app>
910
</root>

build.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@
4040
<echo message="Creating xar file..."/>
4141
<echo message="------------------------------------------------------------"/>
4242

43-
<zip basedir="${basedir}" destfile="${build.dir}/${app.name}-${app.version}.xar">
43+
<zip basedir="${basedir}" destfile="${build.dir}/${app.name}.xar">
4444
<exclude name="${build.dir}/**"/>
4545
<exclude name="*.tmpl"/>
46+
<exclude name=".github/**"/>
47+
<exclude name="test/**"/>
48+
<exclude name="node_modules/**"/>
4649
</zip>
50+
<echo>Version: ${app.version}</echo>
4751
</target>
4852

4953
<target description="Store git revision in ${repository.version}" if="git.present"

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {extends: ['@commitlint/config-angular']}

0 commit comments

Comments
 (0)