Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lint): empty type #16

Merged
merged 3 commits into from
Apr 7, 2024
Merged
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
4 changes: 3 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
interval: "weekly"
commit-message:
prefix: "chore(gha):"
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
xmllint --noout \
$(find . -type f -name '*.xml')

# Build
# Build
- name: Build Expath Package
uses: actions/setup-java@v4
with:
Expand All @@ -45,6 +45,10 @@ jobs:
- run: ant

# Install
- name: add functx
run: wget https://exist-db.org/exist/apps/public-repo/public/functx-1.0.1.xar -O 000.xar
working-directory: build

- name: Start exist-ci containers
run: |
docker run -dit -p 8080:8080 -v ${{ github.workspace }}/build:/exist/autodeploy \
Expand Down
15 changes: 12 additions & 3 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
"branches": ["master"],
"plugins": [
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{ "type": "", "release": "patch" }
]
},
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
},
["@semantic-release/exec", {
"prepareCmd": "ant -Dapp.version=${nextRelease.version}"
}],
Expand All @@ -13,9 +22,9 @@
["@semantic-release/github", {
"assets": [
{
"path": "build/twitter-*.xar",
"name": "twitter-${nextRelease.version}.xar",
"label": "Expath package (twitter-${nextRelease.version}.xar)"
"path": "build/twitter.xar",
"name": "twitter.xar",
"label": "Expath package (twitter.xar)"
}
]
}]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Archive of tweets by the Office of the Historian's official Twitter account, [@H

Releases for this data package are automated. Any commit to the `master`` branch will trigger the release automation.

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:
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 |
|-----------------|--------------|
Expand Down
8 changes: 8 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'body-max-line-length': [1, 'always', 200],
'type-empty': [1, 'never'],
'subject-empty': [1, 'never']
}
}
1 change: 0 additions & 1 deletion commitlint.config.js

This file was deleted.

1 change: 1 addition & 0 deletions expath-pkg.xml.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://expath.org/ns/pkg" name="@url@" abbrev="@name@" version="@version@" spec="1.0">
<title>@title@</title>
<dependency package="http://www.functx.com"/>
</package>
66 changes: 66 additions & 0 deletions modules/dbutil.xqm
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
xquery version "3.1";

(:~
: this version of the dbutil module was copied
: from shared resources v0.9.1
:)
module namespace dbutil="http://exist-db.org/xquery/dbutil";

import module namespace sm="http://exist-db.org/xquery/securitymanager";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";

(:~ Scan a collection tree recursively starting at $root. Call $func once for each collection found :)
declare function dbutil:scan-collections($root as xs:anyURI, $func as function(xs:anyURI) as item()*) {
$func($root),
if (sm:has-access($root, "rx")) then
for $child in xmldb:get-child-collections($root)
return
dbutil:scan-collections(xs:anyURI($root || "/" || $child), $func)
else
()
};

(:~
: List all resources contained in a collection and call the supplied function once for each
: resource with the complete path to the resource as parameter.
:)
declare function dbutil:scan-resources($collection as xs:anyURI, $func as function(xs:anyURI) as item()*) {
if (sm:has-access($collection, "rx")) then
for $child in xmldb:get-child-resources($collection)
return
$func(xs:anyURI($collection || "/" || $child))
else
()
};

(:~
: Scan a collection tree recursively starting at $root. Call the supplied function once for each
: resource encountered. The first parameter to $func is the collection URI, the second the resource
: path (including the collection part).
:)
declare function dbutil:scan($root as xs:anyURI, $func as function(xs:anyURI, xs:anyURI?) as item()*) {
dbutil:scan-collections($root, function($collection as xs:anyURI) {
$func($collection, ()),
(: scan-resources expects a function with one parameter, so we use a partial application
to fill in the collection parameter :)
dbutil:scan-resources($collection, $func($collection, ?))
})
};

declare function dbutil:find-by-mimetype($collection as xs:anyURI, $mimeType as xs:string+) {
dbutil:scan($collection, function($collection, $resource) {
if (exists($resource) and xmldb:get-mime-type($resource) = $mimeType) then
$resource
else
()
})
};

declare function dbutil:find-by-mimetype($collection as xs:anyURI, $mimeType as xs:string+, $func as function(xs:anyURI) as item()*) {
dbutil:scan($collection, function($collection, $resource) {
if (exists($resource) and xmldb:get-mime-type($resource) = $mimeType) then
$func($resource)
else
()
})
};
5 changes: 3 additions & 2 deletions post-install.xql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
xquery version "3.0";

import module namespace xdb="http://exist-db.org/xquery/xmldb";
import module namespace dbutil="http://exist-db.org/xquery/dbutil";
import module namespace dbutil="http://exist-db.org/xquery/dbutil" at "modules/dbutil.xqm";
import module namespace sm="http://exist-db.org/xquery/securitymanager";

(: Specific to this app: :)
import module namespace secrets="http://history.state.gov/ns/xquery/twitter/secrets" at 'modules/twitter-secrets.xqm';
Expand Down Expand Up @@ -85,6 +85,7 @@ let $create-users :=
let $groups := $user/group
let $full-name := $user/full-name
let $user-description := $user/description
(: see #17 :)
return
(
sm:create-account($username, $password, $groups, $full-name, $user-description)
Expand Down
6 changes: 3 additions & 3 deletions pre-install.xql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "3.0";

import module namespace xdb="http://exist-db.org/xquery/xmldb";
import module namespace xmldb="http://exist-db.org/xquery/xmldb";

(: The following external variables are set by the repo:deploy function :)

Expand All @@ -15,7 +15,7 @@ declare function local:mkcol-recursive($collection, $components) {
if (exists($components)) then
let $newColl := concat($collection, "/", $components[1])
return (
xdb:create-collection($collection, $components[1]),
xmldb:create-collection($collection, $components[1]),
local:mkcol-recursive($newColl, subsequence($components, 2))
)
else
Expand All @@ -30,4 +30,4 @@ declare function local:mkcol($collection, $path) {

(: Default task: store the collection configuration :)
local:mkcol("/db/system/config", $target),
xdb:store-files-from-pattern(concat("/system/config", $target), $dir, "*.xconf")
xmldb:store-files-from-pattern(concat("/system/config", $target), $dir, "*.xconf")
3 changes: 1 addition & 2 deletions repo.xml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
<target>twitter</target>
<prepare>pre-install.xql</prepare>
<finish>post-install.xql</finish>
<permissions xmlns:repo="http://exist-db.org/xquery/repo" password="" user="hsg" group="hsg"
mode="rw-rw-r--"/>
<permissions password="" user="hsg" group="hsg" mode="rw-rw-r--"/>
</meta>
6 changes: 4 additions & 2 deletions tests/bats/smoke-test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@

# Make sure the package has been deployed
@test "logs show package deployment" {
result=$(docker logs exist | grep -o 'http://history.state.gov/ns/apps/twitter')
[ "$result" == 'http://history.state.gov/ns/apps/twitter' ]
result=$(docker logs exist | grep -c 'http://history.state.gov/ns/apps/twitter')
[ "$result" -eq 2 ]
}

# see #17
@test "logs are error free" {
skip
result=$(docker logs exist | grep -ow -c 'ERROR' || true)
[ "$result" -eq 0 ]
}
Expand Down