Skip to content

Commit 6df739f

Browse files
authored
Merge pull request #327 from IATI/develop
Next Release
2 parents 5199683 + 551e9e0 commit 6df739f

12 files changed

+86
-63
lines changed

.github/workflows/develop-func-ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- '**/README.md'
77
- '**/dependabot.yml'
88
- 'docs/*'
9+
- '.vscode/*'
910
branches:
1011
- develop
1112
- main

.github/workflows/develop-func-deploy.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- '.github/workflows/prod-func-deploy.yml'
1010
- '.github/workflows/develop-func-ci.yml'
1111
- 'docs/*'
12+
- '.vscode/*'
1213
branches:
1314
- develop
1415
schedule:
@@ -47,7 +48,7 @@ jobs:
4748
uses: actions/checkout@v3
4849

4950
- name: 'Login via Azure CLI'
50-
uses: azure/login@v1.4.4
51+
uses: azure/login@v1.4.5
5152
with:
5253
creds: ${{ env.AZURE_CREDENTIALS }} # Service Principal credentials saved in GitHub Secrets
5354

@@ -148,7 +149,7 @@ jobs:
148149
image: ${{ env.ACR_LOGIN_SERVER }}/func-${{ env.NAME}}-${{ env.STAGE }}:${{ env.TAG }}
149150

150151
- name: 'Tag resource for Tech Climate Impact'
151-
uses: 'azure/CLI@1.0.4'
152+
uses: 'azure/CLI@v1.0.6'
152153
with:
153154
azcliversion: 2.30.0
154155
inlineScript: |
@@ -179,3 +180,14 @@ jobs:
179180
--working-dir integration-tests/test-files \
180181
--env-var keyValue=$API_KEY \
181182
--delay-request 50
183+
184+
# Mark status checks success/fail on dependabot commits for scheduled deploys
185+
status_check_success:
186+
needs: [build-test-deploy, integration-test]
187+
if: success() && github.event_name == 'schedule'
188+
uses: IATI/.github/.github/workflows/status_check_success.yaml@main
189+
190+
status_check_failure:
191+
needs: [build-test-deploy, integration-test]
192+
if: failure() && github.event_name == 'schedule'
193+
uses: IATI/.github/.github/workflows/status_check_failure.yaml@main

.github/workflows/prod-func-deploy.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/checkout@v3
3434

3535
- name: 'Login via Azure CLI'
36-
uses: azure/login@v1.4.4
36+
uses: azure/login@v1.4.5
3737
with:
3838
creds: ${{ env.AZURE_CREDENTIALS }} # Service Principal credentials saved in GitHub Secrets
3939

@@ -134,7 +134,7 @@ jobs:
134134
image: ${{ env.ACR_LOGIN_SERVER }}/func-${{ env.NAME}}-${{ env.STAGE }}:${{ env.TAG }}
135135

136136
- name: 'Tag resource for Tech Climate Impact'
137-
uses: 'azure/CLI@1.0.4'
137+
uses: 'azure/CLI@v1.0.6'
138138
with:
139139
azcliversion: 2.30.0
140140
inlineScript: |

.vscode/extensions.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"recommendations": [
3-
"ms-azuretools.vscode-azurefunctions"
3+
"ms-azuretools.vscode-azurefunctions",
4+
"dbaeumer.vscode-eslint",
5+
"esbenp.prettier-vscode"
46
]
5-
}
7+
}

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"name": "Attach to Node Functions",
2525
"type": "node",
2626
"request": "attach",
27-
"port": 5858,
27+
"port": 9229,
2828
"preLaunchTask": "func: host start"
2929
}
3030
]

.vscode/settings.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@
22
"editor.formatOnSave": true,
33
"files.associations": {
44
"*.xslt": "xml"
5-
}
5+
},
6+
"azureFunctions.deploySubpath": ".",
7+
"azureFunctions.postDeployTask": "npm install (functions)",
8+
"azureFunctions.projectLanguage": "JavaScript",
9+
"azureFunctions.projectRuntime": "~3",
10+
"debug.internalConsoleOptions": "neverOpen",
11+
"azureFunctions.preDeployTask": "npm prune (functions)"
612
}

.vscode/tasks.json

+15-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,21 @@
55
"tasks": [
66
{
77
"type": "func",
8-
"command": "host start --language-worker -- --inspect=5858",
9-
"label": "func: host start",
10-
"problemMatcher": "$func-watch",
11-
"isBackground": true
8+
"command": "host start",
9+
"problemMatcher": "$func-node-watch",
10+
"isBackground": true,
11+
"dependsOn": "npm install (functions)"
12+
},
13+
{
14+
"type": "shell",
15+
"label": "npm install (functions)",
16+
"command": "npm install"
17+
},
18+
{
19+
"type": "shell",
20+
"label": "npm prune (functions)",
21+
"command": "npm prune --production",
22+
"problemMatcher": []
1223
}
1324
]
1425
}

integration-tests/js-validator-api-tests.postman_collection.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"info": {
3-
"_postman_id": "c2e4fc5b-1f70-46cd-b6fb-dec3e0379979",
4-
"name": "js-validator-api-tests",
5-
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
3+
"_postman_id": "f8276da3-7473-469e-ad31-2dbd6b7d46d9",
4+
"name": "js-validator-api-tests bugfix-branch",
5+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
6+
"_exporter_id": "13097277"
67
},
78
"item": [
89
{
@@ -223,7 +224,7 @@
223224
"query": [
224225
{
225226
"key": "",
226-
"value": null,
227+
"value": "",
227228
"disabled": true
228229
}
229230
]
@@ -2407,7 +2408,7 @@
24072408
],
24082409
"body": {
24092410
"mode": "raw",
2410-
"raw": "<iati-activities generated-datetime=\"2014-09-10T07:15:37Z\" version=\"2.03\">\n <iati-activity last-updated-datetime=\"2014-09-10T07:20:37Z\">\n <iati-identifier>ACT-1</iati-identifier>\n <reporting-org ref=\"AA-AAA-123456789\" type=\"40\" secondary-reporter=\"0\">\n <narrative>Organisation name</narrative>\n <narrative xml:lang=\"fr\">Nom de l'organisme</narrative>\n </reporting-org>\n\n <title>\n <narrative>Activity title</narrative>\n <narrative xml:lang=\"fr\">Titre de l'activité</narrative>\n <narrative xml:lang=\"es\">Título de la actividad</narrative>\n </title>\n <activity-date iso-date=\"2012-15-04\" type=\"1\"/>\n <budget type=\"1\" status=\"1\">\n <period-start iso-date=\"2014-15-01\" />\n <period-end iso-date=\"2014-12-31\" />\n <value currency=\"EUR\" value-date=\"2014-01-01\">3000</value>\n </budget>\n\n <fss extraction-date=\"2014-05-06\" priority=\"1\" phaseout-year=\"2016\">\n <forecast year=\"2014\" value-date=\"2013-07-03\" currency=\"GBP\">10000</forecast>\n </fss>\n </iati-activity>\n</iati-activities>"
2411+
"raw": "<iati-activities generated-datetime=\"2014-19-10T07:15:37Z\" version=\"2.03\">\n <iati-activity last-updated-datetime=\"2014-19-10T07:20:37Z\">\n <iati-identifier>ACT-1</iati-identifier>\n <reporting-org ref=\"AA-AAA-123456789\" type=\"40\" secondary-reporter=\"0\">\n <narrative>Organisation name</narrative>\n <narrative xml:lang=\"fr\">Nom de l'organisme</narrative>\n </reporting-org>\n\n <title>\n <narrative>Activity title</narrative>\n <narrative xml:lang=\"fr\">Titre de l'activité</narrative>\n <narrative xml:lang=\"es\">Título de la actividad</narrative>\n </title>\n <description>\n <narrative>Activity title</narrative>\n </description>\n <participating-org role=\"\">\n </participating-org>\n <activity-status code=\"\">\n </activity-status>\n <activity-date iso-date=\"2012-15-04\" type=\"1\"/>\n <budget type=\"1\" status=\"1\">\n <period-start iso-date=\"2014-15-01\" />\n <period-end iso-date=\"2014-12-31\" />\n <value currency=\"EUR\" value-date=\"2014-01-01\">3000</value>\n </budget>\n\n <fss extraction-date=\"2014-05-06\" priority=\"1\" phaseout-year=\"2016\">\n <forecast year=\"2014\" value-date=\"2013-07-03\" currency=\"GBP\">10000</forecast>\n </fss>\n </iati-activity>\n</iati-activities>"
24112412
},
24122413
"url": {
24132414
"raw": "{{baseURL}}/pub/validate?group=false",
@@ -3469,7 +3470,7 @@
34693470
"query": [
34703471
{
34713472
"key": "",
3472-
"value": null,
3473+
"value": "",
34733474
"disabled": true
34743475
}
34753476
]

package-lock.json

+21-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
"devDependencies": {
3030
"@prettier/plugin-xml": "^2.2.0",
3131
"chai": "*",
32-
"eslint": "^8.17.0",
32+
"eslint": "^8.19.0",
3333
"eslint-config-airbnb-base": "^15.0.0",
3434
"eslint-config-prettier": "^8.5.0",
3535
"eslint-plugin-import": "^2.26.0",
3636
"husky": "^8.0.1",
37-
"lint-staged": "^13.0.1",
37+
"lint-staged": "^13.0.3",
3838
"mocha": "*",
39-
"prettier": "^2.7.0"
39+
"prettier": "^2.7.1"
4040
},
4141
"lint-staged": {
4242
"*.js": "eslint --cache --fix",

ruleset-unit-tests/dateNow/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { allRulesResult } = require('../../services/rulesValidator');
99
const testMap = [
1010
{ rule: 'date_now.json', file: 'good.xml', expectedResult: true },
1111
{ rule: 'date_now.json', file: 'bad.xml', expectedResult: false },
12-
{ rule: 'date_now.json', file: 'bad_date_format.xml', expectedResult: false },
12+
{ rule: 'date_now.json', file: 'bad_date_format.xml', expectedResult: 'No Condition Match' },
1313
];
1414

1515
describe('dateNow rules', () => {

services/rulesValidator.js

+10-20
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ const ruleNameObj = require('./ruleNameMap.json');
77

88
const ruleNameMap = new Map(ruleNameObj);
99

10-
const dateReg = /(-?[0-9]{4,})-([0-9]{2})-([0-9]{2})/;
11-
const dateTimeReg = /(-?[0-9]{4,})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/;
12-
1310
const transactionTypes = {
1411
1: 'incoming funds',
1512
2: '(outgoing) commitment',
@@ -290,15 +287,13 @@ class Rules {
290287
if (dateElements.length < 1) return null;
291288
const dateText = dateElements[0].value;
292289
if (dateText !== '') {
293-
if (dateReg.test(dateText)) {
294-
const parsedDate = new Date(dateText);
295-
if (dateReg.test(dateText) && parsedDate.toString() !== 'Invalid Date')
296-
return {
297-
parsedDate,
298-
lineNumber: dateElements[0].lineNumber,
299-
columnNumber: dateElements[0].columnNumber,
300-
};
301-
}
290+
const parsedDate = new Date(dateText);
291+
if (parsedDate.toString() !== 'Invalid Date')
292+
return {
293+
parsedDate,
294+
lineNumber: dateElements[0].lineNumber,
295+
columnNumber: dateElements[0].columnNumber,
296+
};
302297
}
303298
return null;
304299
}
@@ -308,14 +303,9 @@ class Rules {
308303
return compareAsc(this.less.parsedDate, this.more.parsedDate) <= 0;
309304
}
310305

311-
dateNow(oneCase) {
312-
const datetimeElement = xpath(oneCase.date, this.element);
313-
if (datetimeElement.length > 0 && dateTimeReg.test(datetimeElement[0].nodeValue)) {
314-
const selectedDatetime = new Date(datetimeElement[0].nodeValue);
315-
const now = new Date();
316-
return compareAsc(selectedDatetime, now) <= 0;
317-
}
318-
return '';
306+
dateNow() {
307+
if (this.date === null) return '';
308+
return compareAsc(this.date.parsedDate, new Date()) <= 0;
319309
}
320310

321311
betweenDates(oneCase) {

0 commit comments

Comments
 (0)