Skip to content

Commit

Permalink
feat: support publiccode.yml Standard v0.4.0
Browse files Browse the repository at this point in the history
Fix #192.
  • Loading branch information
bfabio committed Jun 14, 2024
1 parent 5f3cded commit 844f349
Show file tree
Hide file tree
Showing 113 changed files with 168 additions and 114 deletions.
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (p *Parser) ParseStream(in io.Reader) (PublicCode, error) {

var ve ValidationResults

if slices.Contains(SupportedVersions, version.Value) && !strings.HasPrefix(version.Value, "0.3") {
if slices.Contains(SupportedVersions, version.Value) && !strings.HasPrefix(version.Value, "0.4") {
latestVersion := SupportedVersions[len(SupportedVersions)-1]
line, column := getPositionInFile("publiccodeYmlVersion", node)

Expand Down
9 changes: 6 additions & 3 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestInvalidTestcasesV0(t *testing.T) {
"publiccodeYmlVersion_invalid.yml": ValidationResults{
ValidationError{
"publiccodeYmlVersion",
"unsupported version: '1'. Supported versions: 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0",
"unsupported version: '1'. Supported versions: 0.2, 0.2.0, 0.2.1, 0.2.2, 0.3, 0.3.0, 0.4, 0.4.0",
0,
0,
},
Expand Down Expand Up @@ -558,7 +558,10 @@ func TestValidWithWarningsTestcasesV0(t *testing.T) {
ValidationWarning{"description.eng.genericName", "This key is DEPRECATED and will be removed in the future", 23, 5},
},
"valid.minimal.v0.2.yml": ValidationResults{
ValidationWarning{"publiccodeYmlVersion", "v0.2 is not the latest version, use '0.3.0'. Parsing this file as v0.3.0.", 1, 1},
ValidationWarning{"publiccodeYmlVersion", "v0.2 is not the latest version, use '0.4.0'. Parsing this file as v0.4.0.", 1, 1},
},
"valid.minimal.v0.3.yml": ValidationResults{
ValidationWarning{"publiccodeYmlVersion", "v0.3 is not the latest version, use '0.4.0'. Parsing this file as v0.4.0.", 1, 1},
},
}

Expand All @@ -580,7 +583,7 @@ func TestDecodeValueErrorsRemote(t *testing.T) {
testRemoteFiles := []testType{
{"https://raw.githubusercontent.com/italia/publiccode-editor/master/publiccode.yml", ValidationResults{
ValidationWarning{
"publiccodeYmlVersion", "v0.2 is not the latest version, use '0.3.0'. Parsing this file as v0.3.0.", 1, 1,
"publiccodeYmlVersion", "v0.2 is not the latest version, use '0.4.0'. Parsing this file as v0.4.0.", 1, 1,
},
ValidationWarning{"description.it.genericName", "This key is DEPRECATED and will be removed in the future", 12, 5},
}},
Expand Down
2 changes: 1 addition & 1 deletion publiccode.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package publiccode

// SupportedVersions lists the publiccode.yml versions this parser supports.
var SupportedVersions = []string{"0.2", "0.2.0", "0.2.1", "0.2.2", "0.3", "0.3.0"}
var SupportedVersions = []string{"0.2", "0.2.0", "0.2.1", "0.2.2", "0.3", "0.3.0", "0.4", "0.4.0"}

type PublicCode interface {
Version() uint
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/applicationSuite_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

# Should NOT validate: applicationSuite must be a string
applicationSuite: []
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/categories_empty.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/categories_invalid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/categories_missing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/categories_nil.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/dependsOn_open_name_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/dependsOn_open_optional_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/dependsOn_open_version_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa

Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/description_eng_awards_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa

Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/description_eng_features_empty.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/description_eng_features_missing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/description_eng_videos_invalid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/description_invalid_language.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/developmentStatus_invalid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/developmentStatus_missing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/developmentStatus_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/file_encoding.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is ISO-8859-1 èñçödëd thus not a valid publiccode.yml.

publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/inputTypes_invalid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/inputTypes_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/intendedAudience_scope_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/intendedAudience_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/invalid_yaml.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/isBasedOn_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/it_riuso_codiceIPA_invalid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/landingURL_invalid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
applicationSuite: MegaProductivitySuite
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/landingURL_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
applicationSuite: MegaProductivitySuite
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/legal_authorsFile_missing_file.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/legal_license_invalid.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/legal_license_missing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/legal_missing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/legal_wrong_type.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/logo_missing_file.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
2 changes: 1 addition & 1 deletion testdata/v0/invalid/logo_unsupported_extension.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
publiccodeYmlVersion: "0.3"
publiccodeYmlVersion: "0.4"

name: Medusa
url: "https://github.com/italia/developers.italia.it.git"
Expand Down
Loading

0 comments on commit 844f349

Please sign in to comment.