Skip to content

Commit

Permalink
Merge pull request #248 from ucoProject/Feature-CP-39
Browse files Browse the repository at this point in the history
Implement CI based on rdf-toolkit and 'make check' design pattern
  • Loading branch information
sbarnum authored May 7, 2021
2 parents c0e821d + fe02f08 commit 0b6d8bb
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 6 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code this software is not subject to copyright
# protection and is in the public domain. NIST assumes no
# responsibility whatsoever for its use by other parties, and makes
# no guarantees, expressed or implied, about its quality,
# reliability, or any other characteristic.
#
# We would appreciate acknowledgement if the software is used.

# This workflow uses Make to confirm ontology files have been
# normalized.

name: Continuous Integration

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Start from clean state
run: make clean
- name: Run tests
run: make check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.jar
.*.ttl
.lib.done.log
59 changes: 59 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/make -f

# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code this software is not subject to copyright
# protection and is in the public domain. NIST assumes no
# responsibility whatsoever for its use by other parties, and makes
# no guarantees, expressed or implied, about its quality,
# reliability, or any other characteristic.
#
# We would appreciate acknowledgement if the software is used.

SHELL := /bin/bash

turtle_directories := $(wildcard uco-*)

all_directories := $(foreach turtle_directory,$(turtle_directories),all-$(turtle_directory))

check_directories := $(foreach turtle_directory,$(turtle_directories),check-$(turtle_directory))

clean_directories := $(foreach turtle_directory,$(turtle_directories),clean-$(turtle_directory))

all: \
$(all_directories)

all-%: \
% \
.lib.done.log
$(MAKE) \
--directory $< \
--file $$PWD/src/review.mk

.lib.done.log:
$(MAKE) \
--directory lib
touch $@

check: \
$(check_directories)

check-%: \
% \
.lib.done.log
$(MAKE) \
--directory $< \
--file $$PWD/src/review.mk \
check

clean: \
$(clean_directories)
@rm -f .lib.done.log

clean-%: \
%
@$(MAKE) \
--directory $< \
--file $$PWD/src/review.mk \
clean
46 changes: 46 additions & 0 deletions lib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/make -f

# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code this software is not subject to copyright
# protection and is in the public domain. NIST assumes no
# responsibility whatsoever for its use by other parties, and makes
# no guarantees, expressed or implied, about its quality,
# reliability, or any other characteristic.
#
# We would appreciate acknowledgement if the software is used.

SHELL := /bin/bash

all: \
rdf-toolkit.jar

# Downloading rdf-toolkit was previously done following the directions
# at:
# https://github.com/edmcouncil/rdf-toolkit
# However, on the file becoming temporarily unavailable, CASE has placed
# a verified copy at a custom location, as a fallback for an alternative
# retrieval from an EDM Council member's repository.
# The checksum of the original file from EDM Council's build server is
# confirmed before moving file into position. (This practice will
# probably require frequent updates, unless a signed checksum for the
# jar can be retrieved somehow.)
# In case there are concerns on potentially multiple writes to the same
# file, the documentation for wget's "--output-document file" flag notes
# that "... file will be truncated immediately, and all downloaded
# content will be written there."
rdf-toolkit.jar:
test -r rdf-toolkit.jar.sha512
# Try retrieval from Github, then from files.caseontology.org.
wget \
--output-document $@_ \
https://github.com/trypuz/openfibo/blob/1f9ab415e8ebd131eadcc9b0fc46241adeeb0384/etc/serialization/rdf-toolkit.jar?raw=true \
|| wget \
--output-document $@_ \
http://files.caseontology.org/rdf-toolkit.jar
test \
"x$$(openssl dgst -sha512 $@_ | awk '{print($$NF)}')" \
== \
"x$$(head -n1 rdf-toolkit.jar.sha512)"
mv $@_ $@
1 change: 1 addition & 0 deletions lib/rdf-toolkit.jar.sha512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24890b4aa484a46803841fbe5938daf60bf2d0889c0e231102c033d71cb84a2bfa8b44419df3ad896d833609afddd4b3910d2ce28660b3350cca22bea0770dad
63 changes: 63 additions & 0 deletions src/review.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/make -f

# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code this software is not subject to copyright
# protection and is in the public domain. NIST assumes no
# responsibility whatsoever for its use by other parties, and makes
# no guarantees, expressed or implied, about its quality,
# reliability, or any other characteristic.
#
# We would appreciate acknowledgement if the software is used.

SHELL := /bin/bash

# This Makefile is assumed to execute in a repository directory /uco-*.
top_srcdir := $(shell cd .. ; pwd)

srcdir := $(shell pwd)

# Determine the basenames of the ontology turtle files.
# Note plurality - this also identifies domain assertion files ("*-da.ttl").
# This computation is done to avoid catching temporary render files (".check-*.ttl")
srcdir_without_ucohyphen := $(subst uco-,,$(shell basename "$(srcdir)"))
ifeq ($(srcdir_without_ucohyphen),master)
ttl_basenames := uco.ttl
else
ttl_basenames := $(wildcard $(srcdir_without_ucohyphen)*.ttl)
endif

# These are reference files, named with a leading dot.
check_reference_basenames := $(foreach ttl_basename,$(ttl_basenames),.check-$(ttl_basename))

# These are recipe targets, not intended to be created files.
check_targets := $(foreach ttl_basename,$(ttl_basenames),check-$(ttl_basename))

all: \
$(check_reference_basenames)

.check-%.ttl: \
%.ttl \
$(top_srcdir)/.lib.done.log
java -jar $(top_srcdir)/lib/rdf-toolkit.jar \
--infer-base-iri \
--inline-blank-nodes \
--source $< \
--source-format turtle \
--target $@_ \
--target-format turtle
mv $@_ $@

check: \
$(check_targets)

# Reminder: diff exits non-0 on finding any differences.
# Reminder: The $^ automatic Make variable is the name of all recipe prerequisites.
check-%.ttl: \
%.ttl \
.check-%.ttl
diff $^

clean:
@rm -f $(check_reference_basenames)
11 changes: 5 additions & 6 deletions uco-observable/observable-da.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ observable:addressOfEntryPoint
rdfs:domain observable:WindowsPEOptionalHeader ;
.


observable:allocationStatus
rdfs:domain observable:FileFacet ;
.
Expand Down Expand Up @@ -490,7 +489,10 @@ observable:diskType
.

observable:displayName
rdfs:domain observable:WindowsServiceFacet ;
rdfs:domain
observable:ContactFacet ,
observable:WindowsServiceFacet
;
.

observable:dllCharacteristics
Expand Down Expand Up @@ -1590,10 +1592,6 @@ observable:scheme
rdfs:domain observable:URLFacet ;
.

observable:displayName
rdfs:domain observable:ContactFacet ;
.

observable:sectionAlignment
rdfs:domain observable:WindowsPEOptionalHeader ;
.
Expand Down Expand Up @@ -2055,3 +2053,4 @@ observable:xMailer
observable:xOriginatingIP
rdfs:domain observable:EmailMessageFacet ;
.

0 comments on commit 0b6d8bb

Please sign in to comment.