Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/npm_and_yarn/es5-ext-0.10.64
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaumanali94 authored May 3, 2024
2 parents 67ac122 + af9c742 commit 86eed86
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 91 deletions.
28 changes: 20 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,26 @@ commands:
git rev-parse HEAD > /tmp/current-commit-sha
cached-dependencies:
parameters:
install-corepack:
type: boolean
default: false
steps:
- restore_cache:
name: Restore Yarn Package Cache
keys:
- &yarn-cache-key yarn-packages-{{ arch }}-{{ checksum "yarn.lock" }}
- when:
condition:
equal:
- true
- << parameters.install-corepack >>
steps:
- run:
name: Enable Corepack
command: |
npm install -g corepack
corepack enable
- run:
name: Install Dependencies
command: yarn install --immutable
Expand Down Expand Up @@ -279,19 +294,15 @@ jobs:
name: windows/default
steps:
- checkout
- run:
name: Enable Corepack
command: |
npm install -g corepack
corepack enable
- cached-dependencies
- cached-dependencies:
install-corepack: true
- build
- test-node:
max-workers: 3
- test-harness:
os: windows
node-version: *node-active-lts
max-workers: 3
max-workers: 2

build-nix-binaries:
docker:
Expand All @@ -315,7 +326,8 @@ jobs:
name: windows/default
steps:
- checkout
- cached-dependencies
- cached-dependencies:
install-corepack: true
- run: yarn build
- build-binary:
targets: windows
Expand Down
64 changes: 5 additions & 59 deletions .github/workflows/jira-issue-label-added.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,13 @@
name: Jira Issue Label Added

# If this needs to be re-used outside of platform-internal,
# then consider a workflow call.
#
# For comparison, see https://github.com/pact-foundation/pact_broker/blob/master/.github/workflows/smartbear-issue-label-added.yml
#

# on:
# workflow_call:
# inputs:
# team-name:
# type: string

on:
issues:
types:
- labeled

jobs:
create-issue-in-stoplight-jira:
runs-on: ubuntu-latest
if: github.event.label.name == 'jira'
steps:
- name: Login
uses: atlassian/gajira-login@v3
with:
team-name: ${{ inputs.team-name }}
env:
JIRA_BASE_URL: ${{ secrets.SMARTBEAR_JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.SMARTBEAR_JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.SMARTBEAR_JIRA_API_TOKEN }}

- name: Search
id: search
uses: tomhjp/[email protected]
with:
jql: 'summary ~ "${{ github.event.repository.name }}#${{ github.event.issue.number }}:" AND project=${{ vars.SMARTBEAR_JIRA_PROJECT }}'

- name: Log
run: echo "Found issue ${{ steps.search.outputs.issue }}"

- name: Create
id: create
uses: atlassian/gajira-create@v3
if: steps.search.outputs.issue == ''
with:
project: ${{ vars.SMARTBEAR_JIRA_PROJECT }}
issuetype: Task
summary: '${{ github.event.repository.name }}#${{ github.event.issue.number }}: ${{ github.event.issue.title }}'
description: |
*Issue Link:* ${{ github.event.issue.html_url }}
${{ github.event.issue.body }}
- name: Add Comment
if: steps.search.outputs.issue == '' && steps.create.outputs.issue != ''
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "This ticket has been labeled <i>jira</i>. A tracking ticket in Stoplight's Jira (<a href='https://smartbear.atlassian.net/browse/${{steps.create.outputs.issue}}'><code>${{steps.create.outputs.issue}}</code></a>) has been created."
})
call-workflow:
uses: stoplightio/.github/.github/workflows/jira-issue-label-added.yaml@master
with:
team-name: ${{ contains(github.event.pull_request.labels.*.name, 'team/bear-claws') && 'Bear Claws' || contains(github.event.pull_request.labels.*.name, 'team/honey-hackers') && 'Honey Hackers' || '' }}
secrets: inherit
34 changes: 21 additions & 13 deletions packages/functions/src/__tests__/xor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ describe('Core Functions / Xor', () => {
]);
});

it('given multiple properties that do not match, should return an error message', async () => {
expect(
await runXor(
{
version: '1.0.0',
title: 'Swagger Petstore',
termsOfService: 'http://swagger.io/terms/',
},
{ properties: ['yada-yada', 'whatever', 'foo'] },
),
).toEqual([
{
message: '"yada-yada", "whatever" and "foo" must not be both defined or both undefined',
path: [],
},
]);
});

it('given both properties, should return an error message', async () => {
expect(
await runXor(
Expand Down Expand Up @@ -99,22 +117,12 @@ describe('Core Functions / Xor', () => {
]),
],
],
[
{ properties: ['foo', 'bar', 'baz'] },
[
new RulesetValidationError(
'invalid-function-options',
'"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]',
['rules', 'my-rule', 'then', 'functionOptions', 'properties'],
),
],
],
[
{ properties: ['foo', {}] },
[
new RulesetValidationError(
'invalid-function-options',
'"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]',
'"xor" and its "properties" option require at least 2-item tuples, i.e. ["id", "name"]',
['rules', 'my-rule', 'then', 'functionOptions', 'properties'],
),
],
Expand All @@ -124,7 +132,7 @@ describe('Core Functions / Xor', () => {
[
new RulesetValidationError(
'invalid-function-options',
'"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]',
'"xor" and its "properties" option require at least 2-item tuples, i.e. ["id", "name"]',
['rules', 'my-rule', 'then', 'functionOptions', 'properties'],
),
],
Expand All @@ -134,7 +142,7 @@ describe('Core Functions / Xor', () => {
[
new RulesetValidationError(
'invalid-function-options',
'"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]',
'"xor" and its "properties" option require at least 2-item tuples, i.e. ["id", "name"]',
['rules', 'my-rule', 'then', 'functionOptions', 'properties'],
),
],
Expand Down
3 changes: 1 addition & 2 deletions packages/functions/src/optionSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ export const optionSchemas: Record<string, CustomFunctionOptionsSchema> = {
type: 'string',
},
minItems: 2,
maxItems: 2,
errorMessage: `"xor" and its "properties" option support 2-item tuples, i.e. ["id", "name"]`,
errorMessage: `"xor" and its "properties" option require at least 2-item tuples, i.e. ["id", "name"]`,
description: 'The properties to check.',
},
},
Expand Down
16 changes: 10 additions & 6 deletions packages/functions/src/xor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ export default createRulesetFunction<Record<string, unknown>, Options>(
options: optionSchemas.xor,
},
function xor(targetVal, { properties }) {
if (properties.length !== 2) return;

const results: IFunctionResult[] = [];

const intersection = Object.keys(targetVal).filter(value => -1 !== properties.indexOf(value));
const intersection = Object.keys(targetVal).filter(key => properties.includes(key));

if (intersection.length !== 1) {
const formattedProperties = properties.map(prop => printValue(prop));

const lastProperty = formattedProperties.pop();
let message = formattedProperties.join(', ') + (lastProperty != undefined ? ` and ${lastProperty}` : '');

message += ' must not be both defined or both undefined';

results.push({
message: `${printValue(properties[0])} and ${printValue(
properties[1],
)} must not be both defined or both undefined`,
message,
});
}

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12454,16 +12454,16 @@ __metadata:
linkType: hard

"tar@npm:^6.0.2, tar@npm:^6.1.0, tar@npm:^6.1.11, tar@npm:^6.1.2":
version: 6.1.15
resolution: "tar@npm:6.1.15"
version: 6.2.1
resolution: "tar@npm:6.2.1"
dependencies:
chownr: ^2.0.0
fs-minipass: ^2.0.0
minipass: ^5.0.0
minizlib: ^2.1.1
mkdirp: ^1.0.3
yallist: ^4.0.0
checksum: f23832fceeba7578bf31907aac744ae21e74a66f4a17a9e94507acf460e48f6db598c7023882db33bab75b80e027c21f276d405e4a0322d58f51c7088d428268
checksum: f1322768c9741a25356c11373bce918483f40fa9a25c69c59410c8a1247632487edef5fe76c5f12ac51a6356d2f1829e96d2bc34098668a2fc34d76050ac2b6c
languageName: node
linkType: hard

Expand Down

0 comments on commit 86eed86

Please sign in to comment.