Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
feat: add barnard-prov vocab
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianvasquez committed Mar 20, 2023
1 parent 404ead2 commit 4baaa9d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
24 changes: 12 additions & 12 deletions lib/metadata/produceProv.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const withoutLastSegment = url => url.split('/')
.splice(0, url.split('/').length - 1)
.join('/')

const ex = namespace('http://example.org/')
const provVocab = namespace('https://barnard-prov.described.at/')

const type = rdf.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')

Expand Down Expand Up @@ -53,30 +53,30 @@ function provFromGitlab () {
const pointer = clownface({ dataset: rdf.dataset(), term: jobUri })

pointer.node(codebaseUri)
.addOut(type, ex.Codebase)
.addOut(ex.hasPipelines, pipelinesUri)
.addOut(type, provVocab.Codebase)
.addOut(provVocab.hasPipelines, pipelinesUri)

pointer.node(commitUri)
.addOut(type, ex.Commit)
.addOut(ex.triggered, pipelineRunUri)
.addOut(type, provVocab.Commit)
.addOut(provVocab.triggered, pipelineRunUri)

pointer.node(pipelinesUri).addOut(ex.contains, pipelineRunUri)
pointer.node(pipelinesUri).addOut(provVocab.contains, pipelineRunUri)

pointer.node(pipelineRunUri)
.addOut(type, ex.PipelineRun)
.addOut(type, provVocab.PipelineRun)
.addOut(prov.startedAtTime, rdf.literal(pipelineRunStartTime, xsd.dateTime))
.addOut(ex.hasJob, jobUri)
.addOut(provVocab.hasJob, jobUri)

pointer.node(jobUri)
.addOut(type, ex.Activity)
.addOut(type, provVocab.Activity)
.addOut(prov.startedAtTime, rdf.literal(jobStartTime, xsd.dateTime))
.addOut(prov.wasTriggeredBy, commitUri)

// Job Optionals
const environment = process.env.CI_BUILD_REF_SLUG
if (environment) {
const environmentUri = ex[`environment/${environment}`]
pointer.node(jobUri).addOut(ex.hasEnvironment, environmentUri)
const environmentUri = provVocab[`environment/${environment}`]
pointer.node(jobUri).addOut(provVocab.hasEnvironment, environmentUri)
}

// Codebase optionals
Expand All @@ -98,7 +98,7 @@ function provFromGitlab () {

const commitAuthor = process.env.CI_COMMIT_AUTHOR
if (commitAuthor) {
pointer.node(commitUri).addOut(ex.author, commitAuthor)
pointer.node(commitUri).addOut(provVocab.author, commitAuthor)
}

const commitTime = process.env.CI_COMMIT_TIMESTAMP
Expand Down
20 changes: 10 additions & 10 deletions test/metadata/produceProv.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ describe('checkGitlabVars', () => {
})
})

const snapshot = `<https://example.org/user/pipeline> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Codebase> .
<https://example.org/user/pipeline> <http://example.org/hasPipelines> <https://example.org/user/pipeline/-/pipelines> .
const snapshot = `<https://example.org/user/pipeline> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://barnard-prov.described.at/Codebase> .
<https://example.org/user/pipeline> <https://barnard-prov.described.at/hasPipelines> <https://example.org/user/pipeline/-/pipelines> .
<https://example.org/user/pipeline> <http://schema.org/description> "Test pipeline" .
<https://example.org/user/pipeline> <http://schema.org/name> "test-pipeline" .
<https://example.org/user/pipeline/-/pipelines> <http://example.org/contains> <https://example.org/user/pipeline/-/pipelines/36212> .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Commit> .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <http://example.org/triggered> <https://example.org/user/pipeline/-/pipelines/36212> .
<https://example.org/user/pipeline/-/pipelines> <https://barnard-prov.described.at/contains> <https://example.org/user/pipeline/-/pipelines/36212> .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://barnard-prov.described.at/Commit> .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <https://barnard-prov.described.at/triggered> <https://example.org/user/pipeline/-/pipelines/36212> .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <http://schema.org/name> "I added the commit title" .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <http://example.org/author> "User <[email protected]>" .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <https://barnard-prov.described.at/author> "User <[email protected]>" .
<https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> <http://www.w3.org/ns/prov#atTime> "2023-03-14T12:24:50+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<https://example.org/user/pipeline/-/pipelines/36212> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/PipelineRun> .
<https://example.org/user/pipeline/-/pipelines/36212> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://barnard-prov.described.at/PipelineRun> .
<https://example.org/user/pipeline/-/pipelines/36212> <http://www.w3.org/ns/prov#startedAtTime> "2023-03-14T12:24:53+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<https://example.org/user/pipeline/-/pipelines/36212> <http://example.org/hasJob> <https://example.org/user/pipeline/-/jobs/48940> .
<https://example.org/user/pipeline/-/jobs/48940> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Activity> .
<https://example.org/user/pipeline/-/pipelines/36212> <https://barnard-prov.described.at/hasJob> <https://example.org/user/pipeline/-/jobs/48940> .
<https://example.org/user/pipeline/-/jobs/48940> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://barnard-prov.described.at/Activity> .
<https://example.org/user/pipeline/-/jobs/48940> <http://www.w3.org/ns/prov#startedAtTime> "2023-03-14T12:25:09+01:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<https://example.org/user/pipeline/-/jobs/48940> <http://www.w3.org/ns/prov#wasTriggeredBy> <https://example.org/user/pipeline/-/commit/30dd92dc282586159c8d4401d26262351f7228e0> .
<https://example.org/user/pipeline/-/jobs/48940> <http://example.org/hasEnvironment> <http://example.org/environment/develop> .
<https://example.org/user/pipeline/-/jobs/48940> <https://barnard-prov.described.at/hasEnvironment> <https://barnard-prov.described.at/environment/develop> .
`

describe('provFromGitlab', () => {
Expand Down

0 comments on commit 4baaa9d

Please sign in to comment.