Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
megahirt committed Apr 4, 2022
2 parents 08dcc47 + 3741d3e commit 852b4b7
Show file tree
Hide file tree
Showing 28 changed files with 843 additions and 120 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/integrate-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,22 @@ jobs:
node-version: '16.14.0'
cache: 'npm'
-
run: npm install
run: npm ci
-
name: Build app
run: docker-compose build --build-arg ENVIRONMENT=production --build-arg BUILD_VERSION=${{ steps.image.outputs.TAG }} app
-
run: docker-compose run --rm app cat /var/www/html/build-version.txt /var/www/html/version.php
-
name: Check unit tests
name: Unit Tests
run: make unit-tests-ci
# -
# name: Check e2e tests
# run: make e2e-tests-ci
-
name: Playwright E2E Tests
working-directory: .
run: |
docker-compose -f docker/docker-compose.yml up -d app-for-playwright
npx playwright install
npx playwright test
-
name: Log in to Docker Hub
uses: docker/login-action@v1
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
-
uses: actions/checkout@v2
-
name: Run Unit Tests
name: Unit Tests
run: make unit-tests-ci
-
name: Publish Test Results
Expand All @@ -31,7 +31,7 @@ jobs:
github_token: ${{ github.token }}
files: docker/PhpUnitTests.xml

build-app:
build-app-run-e2e-tests:
runs-on: ubuntu-latest

steps:
Expand All @@ -43,11 +43,20 @@ jobs:
node-version: '16.14.0'
cache: 'npm'
-
run: npm install
name: Build app
run: |
npm ci
docker-compose build app
-
run: docker-compose build app
name: Playwright E2E Tests
working-directory: .
# see https://playwright.dev/docs/ci#github-actions
run: |
docker-compose -f docker/docker-compose.yml up -d app-for-playwright
npx playwright install
npx playwright test
# e2e-tests:
# protractor-tests:
# runs-on: ubuntu-latest

# steps:
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/set-backlog-fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [ opened ]

jobs:
steve:
add_issue_to_project:
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
Expand All @@ -15,18 +15,18 @@ jobs:
with:
app_id: ${{ secrets.LFPROJECTBOARDAUTOMATION_APP_ID }}
private_key: ${{ secrets.LFPROJECTBOARDAUTOMATION_PRIVATE_KEY }}

- name: determine if issue is already on a project
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPO: ${{ toJson(github.event.repository.name) }}
ORGANIZATION: sillsdev
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
echo issue $ISSUE_NUMBER added to $REPO
gh api graphql -f query='
query($issue_number:Int!, $org:ID!) {
query($issue_number:Int!, $org:String!) {
repository(name:"web-languageforge", owner:$org) {
issue(number: $issue_number) {
id
Expand All @@ -42,6 +42,9 @@ jobs:
echo 'IN_PROJECT='$(jq '.data.repository.issue.projectNextItems[] | length' project_data.json) >> $GITHUB_ENV
- name: get required info for set operations
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ORGANIZATION: sillsdev
run: |
gh api graphql -f query='
query($org: String!) {
Expand All @@ -60,12 +63,13 @@ jobs:
}' -f org=$ORGANIZATION > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Backlog") | .id' project_data.json) >> $GITHUB_ENV
echo 'TRIAGE_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Backlog") | .settings | fromjson.options[] | select(.name=="Triage") | .id' project_data.json) >> $GITHUB_ENV
echo 'FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "ProductOwner") | .id' project_data.json) >> $GITHUB_ENV
echo 'TRIAGE_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "ProductOwner") | .settings | fromjson.options[] | select(.name=="Triage") | .id' project_data.json) >> $GITHUB_ENV
- name: Add issue to project
if: env.IN_PROJECT == 0
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ISSUE_ID: ${{ github.event.issue.node_id }} #use ITEM_ID instead for finding on projects
run: |
item_id="$( gh api graphql -f query='
Expand All @@ -79,8 +83,10 @@ jobs:
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
- name: set Backlog field
- name: set project field
if: env.IN_PROJECT == 0
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
gh api graphql -f query='
mutation(
Expand Down
15 changes: 7 additions & 8 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"JuanCasanova.awesometypescriptproblemmatcher",
"msjsdiag.debugger-for-chrome",
"ms-vscode-remote.remote-containers",
"EditorConfig.editorconfig",
"felixfbecker.php-pack",
"dbaeumer.vscode-eslint",
"emallin.phpunit"
]
"juancasanova.awesometypescriptproblemmatcher",
"msjsdiag.debugger-for-chrome",
"ms-vscode-remote.remote-containers",
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"xdebug.php-pack"
]
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const config: PlaywrightTestConfig = {
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
reporter: process.env.CI ? 'github' : 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
Expand Down
77 changes: 55 additions & 22 deletions src/Api/Model/Shared/DeepDiff/DeepDiffDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,47 @@ public static function applySingleDiff($model, $diff)
$path = $diff->path;
$allButLast = $path; // This is a copy
$last = array_pop($allButLast);
$isLexValue = false;
if ($last === 'value') {
$isLexValue = true;
$last = array_pop($allButLast);
}
$target = $model;
$value = $diff->getValue();
$customFieldsIdx = array_search('customFields', $allButLast, true);
$customFieldData = [];
if ($customFieldsIdx !== false && $customFieldsIdx+2 <= count($path)) {
// Custom fields need special handling
$allButLast = array_slice($path, 0, $customFieldsIdx+2);
$customFieldName = $path[$customFieldsIdx+1];
$rest = array_slice($path, $customFieldsIdx+2);
foreach (\array_reverse($rest) as $step) {
$customFieldData = [$step => $customFieldData];
}
}
// Custom fields need to call MapOf->generate() with a specific shape in order to work:
// For LexValue fields (list fields with a single value): ['value' => (anything)]
// For LexMultiValue fields (list fields where you can choose multiple values): ['values' => (anything)]
// For LexMultiParagraph fields: ['paragraphs' => (anything)] *or* ['type' => 'multiparagraph']
// For LexMultiText fields: ['en' => ['value' => (anything)]], where any writing system can be in place of 'en' here

// The tricky part is distinguishing LexMultiText fields from LexValue fields, hence the slightly-convoluted construction of $customFieldData

$prevStep = '';
foreach ($allButLast as $step) {
$target = static::getNextStep($target, $step);
if ($prevStep === 'customFields') {
$target = static::getCustomFieldStep($target, $step, $customFieldData);
} else {
$target = static::getNextStep($target, $step, $last, $value);
}
if ($target instanceof \Api\Model\Languageforge\Lexicon\LexMultiText && $last === 'value') {
// For MultiText fields, we need $last to be NEXT-to-last step (the writing system), not "value"
$last = $path[count($path) - 2];
// $last = $step;
break;
}
// For a custom single-line MultiText field: [customFields, cf_entry_Cust_Single_Line, en, value] and value is "what was typed"
// For a custom list field, [customFields, cf_entry_Cust_Single_ListRef, value] and value is "what was selected"
$prevStep = $step;
}
if ($diff instanceof ArrayDiff) {
if ($diff->item['kind'] == 'N') {
static::pushValue($target, $last, $diff->getValue());
static::pushValue($target, $last, $value);
} elseif ($diff->item['kind'] == 'D') {
if ($target instanceof \ArrayObject) {
array_pop($target[$last]);
Expand All @@ -94,25 +123,23 @@ public static function applySingleDiff($model, $diff)
// Invalid ArrayDiff; do nothing
}
} else {
static::setValue($target, $last, $diff->getValue());
static::setValue($target, $last, $value);
// TODO: Verify that this works as desired for deletions
}
}

private static function getCustomFieldStep($target, $step, $customFieldData) {
if (isset($target[$step])) {
return $target[$step];
} else {
$object = $target->generate($customFieldData);
$target[$step] = $object;
return $object;
}
}

private static function getNextStep($target, $step) {
if ($target instanceof \Api\Model\Shared\Mapper\MapOf && strpos($step, 'customField_') === 0) {
// Custom fields should be created if they do not exist
if (isset($target[$step])) {
return $target[$step];
} else {
if ($target->hasGenerator()) {
return $target->generate([$step]);
} else {
// This will probably fail
return $target[$step];
}
}
} else if ($target instanceof \ArrayObject) {
if ($target instanceof \ArrayObject) {
return $target[$step];
} else {
return $target->$step;
Expand All @@ -122,10 +149,16 @@ private static function getNextStep($target, $step) {
private static function setValue(&$target, $last, $value) {
if ($target instanceof \Api\Model\Languageforge\Lexicon\LexMultiText) {
$target->form($last, $value);
} else if ($target instanceof \Api\Model\Languageforge\Lexicon\LexValue) {
$target->value($value); // TODO: Test this
} else if ($target instanceof \ArrayObject) {
$target[$last] = $value;
} else {
$target->$last = $value;
if ($target->$last instanceof \Api\Model\Languageforge\Lexicon\LexValue) {
$target->$last->value($value);
} else {
$target->$last = $value;
}
}
}

Expand Down
Loading

0 comments on commit 852b4b7

Please sign in to comment.