Skip to content
Open
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
31 changes: 16 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
version: 2.1
setup: true

orbs:
python: circleci/python@2.0.3
jobs:
check schemas:
docker:
- image: cimg/python:3.8
steps:
- checkout
- python/install-packages:
args: '--dev'
venv-cache: true
pkg-manager: pipenv
- run:
command: pipenv run pytest
continuation: circleci/continuation@0.1.2
path-filtering: circleci/path-filtering@0.0.2

workflows:
check schemas:
always-run:
jobs:
- check schemas
- path-filtering/filter:
name: check-updated-files
mapping: |
projects/python/.* python true
projects/golang/.* golang true
projects/csharp/.* csharp true
projects/rust/.* rust true
projects/nim/.* nimlang true
.circleci/.* build-all true
base-revision: master
config-path: .circleci/test_langs.yml
82 changes: 82 additions & 0 deletions .circleci/test_langs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
version: 2.1

orbs:
python: circleci/python@2.1.1
go: circleci/go@1.7.3

parameters:
python:
type: boolean
default: false
golang:
type: boolean
default: false
csharp:
type: boolean
default: false
rust:
type: boolean
default: false
nimlang:
type: boolean
default: false
build-all:
type: boolean
default: false

jobs:
python:
parameters:
appname:
type: string
default: ""
docker:
- image: cimg/python:3.10
steps:
- checkout
- python/install-packages:
venv-cache: true
app-dir: projects/python
pkg-manager: poetry
- run:
command: |
cd projects/python
poetry run pytest

golang:
parameters:
appname:
type: string
default: ""
docker:
- image: cimg/go:1.20.5
steps:
- checkout
- run: cd projects/golang
- run:
command: |
cd projects/golang
go mod download
- run:
command: |
cd projects/golang
go test



workflows:
version: 2
python:
when: << pipeline.parameters.python >>
jobs:
- python:
filters:
branches:
ignore: master
golang:
when: << pipeline.parameters.golang >>
jobs:
- golang:
filters:
branches:
ignore: master
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.swp
*.pyc
*__pycache__/
dist/
3 changes: 3 additions & 0 deletions projects/golang/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module civichacker/lovelanguage

go 1.18
8 changes: 8 additions & 0 deletions projects/golang/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package main

import (
"embed"
)

//go:embed schemas/*.json
var schemas embed.FS
29 changes: 29 additions & 0 deletions projects/golang/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"testing"
"encoding/json"
"fmt"
)

func TestSchemaLoading(t *testing.T){
var tests = []struct {
name string
filename string
}{
// the table itself
{"use of force", "schemas/use-of-force.schema"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
content, err := schemas.ReadFile(fmt.Sprintf("%s.json", tt.filename))
result := json.Valid([]byte(content))

if err != nil {
t.Errorf("loading schema failed: %s", err)
} else if !result {
t.Errorf("schema is not valid JSON")
}
})
}
}
69 changes: 69 additions & 0 deletions projects/golang/schemas/use-of-force.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"$id": "https://raw.githubusercontent.com/civichacker/love-language/master/schemas/use-of-force.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "x-use-of-force",
"description": "Most law enforcement agencies have policies that guide their use of force. These policies describe a escalating series of actions an officer may take to resolve a situation. This continuum generally has many levels, and officers are instructed to respond with a level of force appropriate to the situation at hand, acknowledging that the officer may move from one part of the continuum to another in a matter of seconds. https://nij.ojp.gov/topics/articles/use-force-continuum",
"type": "object",
"allOf": [
{
"$ref": "https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sros/relationship.json"
},
{
"properties": {
"x_civichacker_deadly_force": {
"type": "string",
"enum": [
"anticipatory",
"premptive",
"reactive"
]
},
"source_ref": {
"type": "string",
"pattern": "^(incident|identity)--"
},
"target_ref": {
"type": "string",
"pattern": "^identity--"
},
"x_civichacker_force_applied": {
"type": "string",
"description": "Indicates where on the Use of Force continuum force was used.",
"enum": [
"presence",
"verbalization",
"empty-hand-control",
"less-lethal-methods",
"lethal-force"
]
}
}
},
{
"if": {
"properties": {
"extensions": {
"type": "object",
"required": ["extension-definition--9c59fd79-4215-4ba2-920d-3e4f320e1e62"]
}
}
},
"then": {
"required": ["x_civichacker_use_of_force"]
}
},
{
"if": {
"properties": {
"x_civichacker_use_of_force": {
"type": "string",
"pattern": "^lethal-force$"
}
}
},
"then": {
"required": ["x_civichacker_deadly_force"]
}
}
]
}
Empty file added projects/python/README.md
Empty file.
5 changes: 5 additions & 0 deletions projects/python/lovelanguage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from importlib.resources import files

USEOFFORCE = files('lovelanguage.schemas').joinpath('use-of-force.schema.json').read_text()

__all__ = ['USEOFFORCE']
Empty file.
69 changes: 69 additions & 0 deletions projects/python/lovelanguage/schemas/use-of-force.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"$id": "https://raw.githubusercontent.com/civichacker/love-language/master/schemas/use-of-force.schema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "x-use-of-force",
"description": "Most law enforcement agencies have policies that guide their use of force. These policies describe a escalating series of actions an officer may take to resolve a situation. This continuum generally has many levels, and officers are instructed to respond with a level of force appropriate to the situation at hand, acknowledging that the officer may move from one part of the continuum to another in a matter of seconds. https://nij.ojp.gov/topics/articles/use-force-continuum",
"type": "object",
"allOf": [
{
"$ref": "https://raw.githubusercontent.com/oasis-open/cti-stix2-json-schemas/stix2.1/schemas/sros/relationship.json"
},
{
"properties": {
"x_civichacker_deadly_force": {
"type": "string",
"enum": [
"anticipatory",
"premptive",
"reactive"
]
},
"source_ref": {
"type": "string",
"pattern": "^(incident|identity)--"
},
"target_ref": {
"type": "string",
"pattern": "^identity--"
},
"x_civichacker_force_applied": {
"type": "string",
"description": "Indicates where on the Use of Force continuum force was used.",
"enum": [
"presence",
"verbalization",
"empty-hand-control",
"less-lethal-methods",
"lethal-force"
]
}
}
},
{
"if": {
"properties": {
"extensions": {
"type": "object",
"required": ["extension-definition--9c59fd79-4215-4ba2-920d-3e4f320e1e62"]
}
}
},
"then": {
"required": ["x_civichacker_use_of_force"]
}
},
{
"if": {
"properties": {
"x_civichacker_use_of_force": {
"type": "string",
"pattern": "^lethal-force$"
}
}
},
"then": {
"required": ["x_civichacker_deadly_force"]
}
}
]
}
Loading