Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into issue-29479-Create-…
Browse files Browse the repository at this point in the history
…a-default-JobQueue-Implementation-using-Postgres
  • Loading branch information
jgambarios committed Sep 17, 2024
2 parents a15d7c8 + cf8a74a commit c8a91cd
Show file tree
Hide file tree
Showing 21 changed files with 2,248 additions and 371 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ runs:
shell: bash

- name: 'Publishing sdk into NPM registry'
if: ${{ steps.validate_version.outputs.publish == 'true' }}
working-directory: ${{ github.workspace }}/core-web/libs/sdk/
env:
NEXT_VERSION: ${{ steps.next_version.outputs.next_version }}
Expand Down
78 changes: 74 additions & 4 deletions .github/workflows/cicd_comp_initialize-phase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,98 @@ jobs:
steps:
- uses: actions/checkout@v4
if: ${{ inputs.validation-level != 'none' }}

- name: Determine BASE_SHA
id: determine-base-sha
run: |
echo "::group::Determine BASE_SHA"
# 1 - PULL REQUEST || 2 - MERGE GROUP || 3 - PUSH || 4 - DEFAULT
BASE_SHA=${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before || github.sha }}
echo "::notice::BASE SHA: ${BASE_SHA}"
echo "BASE_SHA=${BASE_SHA}" >> $GITHUB_ENV
echo "::endgroup::"
# 1. Attempt to download the existing artifact using the BASE_SHA
- name: Download Existing SDK Status Artifact
if: ${{ github.event_name != 'pull_request' }}
id: download-artifact
uses: dawidd6/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow_search: true
search_artifacts: true
name: sdk-status-sha-${{ env.BASE_SHA }} # Name of the artifact using BASE_SHA
path: .
if_no_artifact_found: warn
continue-on-error: true # Do not fail if the artifact does not exist

# 2. Check if the artifact was downloaded
- name: Check if SDK Status exists
id: check-artifact
run: |
echo "::group::Check if SDK Status exists"
if [ -f sdk_status_sha_${{ env.BASE_SHA }}.txt ]; then
echo "Artifact found. Using existing sdk_status."
sdk_libs=$(cat sdk_status_sha_${{ env.BASE_SHA }}.txt | grep 'sdk_libs' | cut -d'=' -f2)
echo "sdk_libs=$sdk_libs"
echo "sdk_libs=$sdk_libs" >> $GITHUB_ENV
else
echo "Artifact not found. Calculating sdk_status..."
echo "sdk_status_not_found=true"
echo "sdk_status_not_found=true" >> $GITHUB_ENV
fi
# Correctly closing the if statement
echo "::endgroup::"
# Execute the paths-filter step to determine changes
- uses: dorny/[email protected]
if: ${{ inputs.validation-level != 'none' }}
id: filter
with:
filters: .github/filters.yaml
list-files: 'escape'

# 3. Calculate sdk_status if it does not exist
- name: Calculate SDK Status
if: env.sdk_status_not_found == 'true'
run: |
echo "::group::Calculating sdk_status"
# Logic to determine sdk_status
sdk_libs=${{ steps.filter.outputs.sdk_libs || 'false' }} # Default value in case of failure
echo "sdk_libs=$sdk_libs" > sdk_status_sha_${{ env.BASE_SHA }}.txt
echo "sdk_libs=$sdk_libs"
echo "$(cat sdk_status_sha_${{ env.BASE_SHA }}.txt)"
echo "sdk_libs=$sdk_libs" >> $GITHUB_ENV
echo "::endgroup::"
# 4. Upload the sdk_status as an artifact if it was calculated
- name: Upload SDK Status Artifact
if: env.sdk_status_not_found == 'true'
uses: actions/upload-artifact@v4
with:
name: sdk-status-sha-${{ env.BASE_SHA }} # Name of the artifact using BASE_SHA
path: sdk_status_sha_${{ env.BASE_SHA }}.txt
retention-days: 30 # Configure retention period as needed

- name: Rewrite Filter
id: filter-rewrite
env:
CICD_SKIP_TESTS: ${{ vars.CICD_SKIP_TESTS }}
SDK_LIBS: ${{ env.sdk_libs }}
run: |
echo "::group::Rewrite Fiter"
# Default action outcomes based on paths-filter action outputs
frontend=${{ steps.filter.outputs.frontend || 'true'}}
cli=${{ steps.filter.outputs.cli || 'true' }}
backend=${{ steps.filter.outputs.backend || 'true' }}
build=${{ steps.filter.outputs.build || 'true' }}
jvm_unit_test=${{ steps.filter.outputs.jvm_unit_test || 'true' }}
sdk_libs=${{ steps.filter.outputs.sdk_libs || 'false' }}
sdk_libs=${{ env.SDK_LIBS || steps.filter.outputs.sdk_libs }} # Use the recovered or calculated value
# Check if the commit is to the master branch
skip_tests=${CICD_SKIP_TESTS:-false} # Use environment variable, default to 'false'
# The below line ensures that if skip_tests is true, all tests are set to false.
# If skip_tests is true, set all tests to false
if [ "$skip_tests" == "true" ]; then
echo "Skipping tests as per CICD_SKIP_TESTS flag."
frontend=false
Expand Down Expand Up @@ -175,7 +244,7 @@ jobs:
elif [ "${module}" == "jvm_unit_test" ]; then
jvm_unit_test=${{ steps.filter.outputs.jvm_unit_test }}
elif [ "${module}" == "sdk_libs" ]; then
sdk=${{ steps.filter.outputs.sdk_libs }}
sdk_libs=${{ env.SDK_LIBS }} # Use the recovered or calculated value
fi
done
fi
Expand All @@ -193,4 +262,5 @@ jobs:
echo "backend=${backend}" >> $GITHUB_OUTPUT
echo "build=${build}" >> $GITHUB_OUTPUT
echo "jvm_unit_test=${jvm_unit_test}" >> $GITHUB_OUTPUT
echo "sdk_libs=${sdk_libs}" >> $GITHUB_OUTPUT
echo "sdk_libs=${sdk_libs}" >> $GITHUB_OUTPUT
echo "::endgroup::"
50 changes: 32 additions & 18 deletions .github/workflows/cicd_scheduled_notify-seated-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ on:
schedule:
- cron: '0 10 * * *'
workflow_dispatch:
inputs:
current_user:
description: 'Limit execution of this workflow to the current user'
type: string
required: false
default: U0125JCDSSE
env:
PR_DAY_THRESHOLD: 3
DRAFT_PR_DAY_THRESHOLD: 5
Expand All @@ -20,6 +26,7 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Filter execution
id: filter-execution
uses: actions/github-script@v7
with:
result-encoding: string
Expand All @@ -28,11 +35,13 @@ jobs:
console.log(new Date());
if (day === 0 || day === 6) {
console.log('It\'s (happy) weekend, not sending any notifications');
process.exit(1);
process.exit(0);
}
core.setOutput('continue', 'true');
- id: fetch-seated-prs
name: Fetch Seated PRs
if: success()
if: success() && steps.filter-execution.outputs.continue == 'true'
uses: actions/github-script@v7
with:
result-encoding: string
Expand Down Expand Up @@ -146,23 +155,25 @@ jobs:
with:
result-encoding: string
script: |
const member = '${{ matrix.member }}';
const urlMapper = (pr) => `- ${pr.url}`;
const prDayThreshold = ${{ env.PR_DAY_THRESHOLD }};
const draftPrDayThreshold = ${{ env.DRAFT_PR_DAY_THRESHOLD }};
const seatedPrs = ${{ needs.resolve-seated-prs.outputs.seated_prs }}
const mappings = ${{ needs.slack-channel-resolver.outputs.mappings_json }};
const foundMapping = mappings.find(mapping => mapping.slack_id === member)
if (!foundMapping) {
core.warning(`Slack user Id [${member}] cannot be found, exiting`);
process.exit(0);
}

const members = ${{ needs.resolve-seated-prs.outputs.members_json }}
const channels = ${{ needs.slack-channel-resolver.outputs.channel_ids }}
console.log(JSON.stringify(members, null, 2));
console.log(JSON.stringify(channels, null, 2));

const idx = channels.findIndex(channel => channel === '${{ matrix.member }}');
if (idx === -1) {
console.log('Could not find channel [${{ matrix.member }}], skipping this');
process.exit(2);
}
const login = members[idx];
const login = foundMapping.github_user;
const userPrs = seatedPrs.find(pr => pr.login === login);
const prs = userPrs.prs.filter(pr => !pr.draft).map(urlMapper);
const draftPrs = userPrs.prs.filter(pr => pr.draft).map(urlMapper);
Expand All @@ -183,14 +194,17 @@ jobs:

core.setOutput('message', message);
- name: Notify member
if: success()
if: success() && steps.build-message.outputs.message != ''
shell: bash
run: |
channel=${{ matrix.member }}
curl -X POST \
-H "Content-type: application/json" \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
-d "{ \"channel\":\"${channel}\",\"text\":\"${{ steps.build-message.outputs.message }}\"}" \
-s \
https://slack.com/api/chat.postMessage
echo "Sending notification to ${channel}"
if [[ -x '${{ inputs.current_user }}' || "${channel}" == '${{ inputs.current_user }}' ]]; then
curl -X POST \
-H "Content-type: application/json" \
-H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" \
-d "{ \"channel\":\"${channel}\",\"text\":\"${{ steps.build-message.outputs.message }}\" }" \
-s \
https://slack.com/api/chat.postMessage
fi
36 changes: 16 additions & 20 deletions .github/workflows/issue_comp_next-release-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,38 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Validate inputs
id: validate-inputs
uses: actions/github-script@v7
with:
result-encoding: string
script: |
let issueNumber;
const issue = context.payload.issue;
if (!issue && '${{ inputs.issue_number }}'.trim() === '') {
console.log('Issue number is not provided');
process.exit(1);
core.warn('Issue number is not provided');
process.exit(0);
}
let label = context.payload.label;
if (!label) {
if (!'${{ inputs.label }}') {
console.log('Label is missing, exiting');
process.exit(2);
core.warn('Label is missing, exiting');
process.exit(0);
}
label = '${{ inputs.label }}';
} else {
label = label.name;
}
if (label !== '${{ env.QA_NOT_NEEDED_LABEL }}') {
console.log('Label is not [${{ env.QA_NOT_NEEDED_LABEL }}], exiting');
process.exit(3);
core.warn('Label is not [${{ env.QA_NOT_NEEDED_LABEL }}], exiting');
process.exit(0);
}
core.setOutput('label', label);
- name: Add Next Release label
uses: actions/github-script@v7
if: success()
if: success() && steps.validate-inputs.outputs.label != ''
with:
result-encoding: string
retries: 3
Expand All @@ -81,25 +82,25 @@ jobs:
}
if (!issue) {
console.log('Issue [${{ inputs.issue_number }}] not found');
process.exit(4);
core.warn('Issue [${{ inputs.issue_number }}] not found');
process.exit(0);
}
}
console.log(`Issue: ${JSON.stringify(issue, null, 2)}`);
const issueNumber = issue.number;
const dropAndLearnText = 'Drop Everything & Learn';
if (issue.title.includes(dropAndLearnText)) {
console.log(`Issue does have "${dropAndLearnText}" text in title, exiting`);
process.exit(5);
const dropAndLearnText = 'Drop Everything & Learn'.toLowerCase();
if (issue.title.toLowerCase().includes(dropAndLearnText)) {
core.warn(`Issue does have "${dropAndLearnText}" text in title, exiting`);
process.exit(0);
}
const typeCicdLabel = 'Type : CI/CD';
const foundLabel = issue.labels.find(label => label.name === typeCicdLabel);
if (foundLabel) {
console.log(`Issue does have "${typeCicdLabel}" label , exiting`);
process.exit(6);
core.warn(`Issue does have "${typeCicdLabel}" label , exiting`);
process.exit(0);
}
await github.rest.issues.addLabels({
Expand All @@ -111,9 +112,4 @@ jobs:
const updated = await getIssue(issueNumber);
console.log(`Labels: ${JSON.stringify(updated.labels, null, 2)}`);
- name: Finalize
if: always()
run: |
echo 'Finalizing Next release labeling'
exit 0
11 changes: 9 additions & 2 deletions .github/workflows/utility_slack-channel-resolver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ on:
outputs:
channel_ids:
value: ${{ jobs.slack-channel-resolver.outputs.channel_ids }}
mappings_json:
value: ${{ jobs.slack-channel-resolver.outputs.mappings_json }}
secrets:
CI_MACHINE_USER:
description: 'CI machine user'
Expand All @@ -45,6 +47,7 @@ jobs:
runs-on: ubuntu-20.04
outputs:
channel_ids: ${{ steps.resolve-channels.outputs.channel_ids }}
mappings_json: ${{ steps.resolve-channels.outputs.mappings_json }}
steps:
- name: Resolve Users
id: resolve-users
Expand All @@ -70,7 +73,8 @@ jobs:
githack_core_repo_url=https://${githack_host}/${{ github.repository }}
slack_mappings_file=slack-mappings.json
slack_mapping_url=${githack_core_repo_url}/${{ inputs.branch }}/.github/data/${slack_mappings_file}
json=$(curl -s ${slack_mapping_url})
json=$(curl -s ${slack_mapping_url} | jq -c .)
echo "json: ${json}"
echo "Looking for [${github_user}]"
channel_ids=
Expand Down Expand Up @@ -115,7 +119,9 @@ jobs:
fi
fi
[[ -n "${channel_id}" ]] && channel_ids="${channel_ids} ${channel_id}"
if [[ -n "${channel_id}" && "${channel_id}" != 'null' ]]; then
channel_ids="${channel_ids} ${channel_id}"
fi
done
default_channel_id=${{ inputs.default_channel_id }}
Expand All @@ -135,5 +141,6 @@ jobs:
channel_ids=$(printf '%s\n' "${deduped_channel_ids[@]}" | jq -R . | jq -s . | tr -d '\n' | tr -d ' ')
fi
echo "mappings_json=${json}" >> $GITHUB_OUTPUT
echo "channel_ids: [${channel_ids}]"
echo "channel_ids=${channel_ids}" >> $GITHUB_OUTPUT
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ describe('DotContentTypesPortletComponent', () => {

describe('filterBy', () => {
beforeEach(() => {
router.queryParams = of({
router.data = of({
filterBy: 'FORM'
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class DotContentTypesPortletComponent implements OnInit, OnDestroy {
map((environments: DotEnvironment[]) => !!environments.length),
take(1)
),
this.route.queryParams.pipe(pluck('filterBy'), take(1))
this.route.data.pipe(pluck('filterBy'), take(1))
).subscribe(([contentTypes, isEnterprise, environments, filterBy]) => {
const baseTypes: StructureTypeView[] = contentTypes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,22 @@ describe('UVEStore', () => {

expect(layoutItem.isDisabled).toBe(true);
});
it('should return layout, rules and experiments as disabled when isEnterprise is false', () => {
jest.spyOn(dotPageApiService, 'get').mockImplementation(
buildPageAPIResponseFromMock(MOCK_RESPONSE_VTL)
);

patchState(store, { isEnterprise: false });

const shellProps = store.$shellProps();
const layoutItem = shellProps.items.find((item) => item.id === 'layout');
const rulesItem = shellProps.items.find((item) => item.id === 'rules');
const experimentsItem = shellProps.items.find((item) => item.id === 'experiments');

expect(layoutItem.isDisabled).toBe(true);
expect(rulesItem.isDisabled).toBe(true);
expect(experimentsItem.isDisabled).toBe(true);
});
it('should return item for layout as disable and with a tooltip', () => {
jest.spyOn(dotPageApiService, 'get').mockImplementation(
buildPageAPIResponseFromMock({
Expand Down
Loading

0 comments on commit c8a91cd

Please sign in to comment.