Skip to content

Commit

Permalink
Merge branch 'release51' into test/release51
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl committed Dec 4, 2024
2 parents 8c16ce8 + d2a3cdf commit 96993d0
Show file tree
Hide file tree
Showing 103 changed files with 4,454 additions and 335 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
CI: true
- name: Send coverage
if: ((github.event_name == 'pull_request') && (!startsWith(github.head_ref, 'release'))) || ((github.event_name == 'push') && (!startsWith(github.ref_name, 'release')))
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
echo "image=$image" >> $GITHUB_OUTPUT
- name: Trivy scanning
if: steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
uses: aquasecurity/trivy-action@0.24.0
uses: aquasecurity/trivy-action@0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
with:
Expand Down Expand Up @@ -390,7 +390,7 @@ jobs:
echo "image=$image" >> $GITHUB_OUTPUT
- name: Trivy scanning
if: steps.check-build-and-push.outputs.enable == 'true' && steps.check-ghcr.outputs.enable == 'true' && steps.ghcr-tag.outputs.tags != 0
uses: aquasecurity/trivy-action@0.24.0
uses: aquasecurity/trivy-action@0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
with:
Expand Down Expand Up @@ -525,7 +525,7 @@ jobs:
CI: true
- name: Send coverage
if: (matrix.node-version == '16.x' || matrix.send-coverage == true) && ((github.event_name == 'pull_request') && ((!startsWith(github.head_ref, 'release'))) || ((github.event_name == 'push') && (!startsWith(github.ref_name, 'release'))))
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down Expand Up @@ -748,6 +748,6 @@ jobs:
CI: true
- name: Run check
run: |
node scripts/checkForMultipleVersions.mjs
yarn validate:versions
env:
CI: true
83 changes: 34 additions & 49 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Scheduled Trivy Scan
on:
workflow_dispatch:
schedule:
- cron: '0 10 * * 1'
- cron: "0 10 * * 1"

jobs:
trivy:
Expand All @@ -17,21 +17,21 @@ jobs:

steps:
- name: Run Trivy vulnerability scanner (json)
uses: aquasecurity/trivy-action@0.24.0
uses: aquasecurity/trivy-action@0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
with:
image-ref: ghcr.io/nrkno/sofie-core-${{ matrix.image }}:latest
format: json
output: '${{ matrix.image }}-trivy-scan-results.json'
output: "${{ matrix.image }}-trivy-scan-results.json"

- name: Run Trivy vulnerability scanner (table)
uses: aquasecurity/trivy-action@0.24.0
uses: aquasecurity/trivy-action@0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
with:
image-ref: ghcr.io/nrkno/sofie-core-${{ matrix.image }}:latest
output: '${{ matrix.image }}-trivy-scan-results.txt'
output: "${{ matrix.image }}-trivy-scan-results.txt"

- name: Post all scan results to Github Summary as a table
env:
Expand All @@ -44,12 +44,12 @@ jobs:
echo $CODE_BLOCK >> $GITHUB_STEP_SUMMARY
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
uses: aquasecurity/trivy-action@0.24.0
uses: aquasecurity/trivy-action@0.29.0
env:
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
with:
format: 'github'
output: 'dependency-results-${{ matrix.image }}.sbom.json'
format: "github"
output: "dependency-results-${{ matrix.image }}.sbom.json"
image-ref: ghcr.io/nrkno/sofie-core-${{ matrix.image }}:latest
github-pat: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -64,46 +64,31 @@ jobs:
echo ${{ env.SUMMARY }}
- name: Send Slack Notification
uses: slackapi/slack-github-action@v1.27.0
uses: slackapi/slack-github-action@v2.0.0
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"text": "Trivy scan results",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Trivy scan results for sofie-core-${{ matrix.image }}:latest"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":thisisfine: ${{ env.SUMMARY }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Read the full scan results on Github"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": ":github: Scan results",
"emoji": true
},
"value": "workflow_run",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"action_id": "button-action"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
text: "Trivy scan results"
blocks:
- type: "header"
text:
type: "plain_text"
text: "Trivy scan results for sofie-core-${{ matrix.image }}:latest"
- type: "section"
text:
type: "mrkdwn"
text: ":thisisfine: ${{ env.SUMMARY }}"
- type: "section"
text:
type: "mrkdwn"
text: "Read the full scan results on Github"
accessory:
type: "button"
text:
type: "plain_text"
text: ":github: Scan results"
emoji: true
value: "workflow_run"
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
action_id: "button-action"
18 changes: 18 additions & 0 deletions meteor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.51.4](///compare/v1.51.3...v1.51.4) (2024-12-04)


### Bug Fixes

* Device Action Studio Context gets lost, Adlib previews are unstable 193815d
* Live Status Gateway Dockerfile (regular) still uses yarn to start 0ae53c4
* release scripts broken on Windows 9636051
* RundownView shows spinner when unMOSing a Rundown from a Playlist 874e85c

### [1.51.2](https://github.com/nrkno/tv-automation-server-core/compare/v1.51.1...v1.51.2) (2024-11-21)


### Bug Fixes

* Include previousPartInstance in check to orphan segments rather than remove them. ([2c113b5](https://github.com/nrkno/tv-automation-server-core/commit/2c113b58b205198d13f0fc7e2114704311eb915b))
* updatePartInstancesSegmentIds: take into account when multiple segments have been merged into one. ([bdab8c4](https://github.com/nrkno/tv-automation-server-core/commit/bdab8c4e4ee1e67a3568cccc98106bb7f1258673))

## [1.51.0-in-testing.3](https://github.com/nrkno/sofie-core/compare/v1.51.0-in-testing.2...v1.51.0-in-testing.3) (2024-09-25)

## [1.51.0-in-testing.2](https://github.com/nrkno/sofie-core/compare/v1.51.0-in-testing.1...v1.51.0-in-testing.2) (2024-09-24)
Expand Down
136 changes: 127 additions & 9 deletions meteor/client/lib/ReactMeteorData/ReactMeteorData.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/prefer-stateless-function */

import React, { useState, useEffect, useRef } from 'react'
import React, { useState, useEffect, useRef, useCallback } from 'react'
import { Meteor } from 'meteor/meteor'
import { Mongo } from 'meteor/mongo'
import { Tracker } from 'meteor/tracker'
Expand All @@ -13,6 +13,8 @@ const globalTrackerQueue: Array<Function> = []
let globalTrackerTimestamp: number | undefined = undefined
let globalTrackerTimeout: number | undefined = undefined

const SUBSCRIPTION_TIMEOUT = 1000

/**
* Delay an update to be batched with the global tracker invalidation queue
*/
Expand Down Expand Up @@ -370,6 +372,61 @@ export function useTracker<T, K extends undefined | T = undefined>(
return meteorData
}

/**
* A hook to track a boolean state with a sort of histeresis, with preference for `true`. `setState` makes the returned
* `state` be `true` immediately, but `false` only after `resetState` is called and `timeout` elapses. If `setState`
* is called with `true` before `timeout` elapses, then `resetState` is aborted and `state` will remain `ture.
*
* Later `resetState` calls replace earlier unelapsed calls and their timeout periods.
*
* @param {boolean} [initialState=false]
* @return {*} {{
* state: boolean
* setState: (value: boolean) => void
* resetState: (timeout: number) => void
* }}
*/
function useDelayState(initialState = false): {
state: boolean
setState: (value: boolean) => void
resetState: (timeout: number) => void
} {
const [state, setState] = useState(initialState)
const [prevState, setPrevState] = useState(initialState)
const prevReadyTimeoutRef = useRef<number | null>(null)

const setStateAndClearResets = useCallback(
(value: boolean) => {
setState(value)

if (value) {
setPrevState(true)
if (prevReadyTimeoutRef.current !== null) {
window.clearTimeout(prevReadyTimeoutRef.current)
prevReadyTimeoutRef.current = null
}
}
},
[setState, setPrevState]
)

const resetStateAfterDelay = useCallback((timeout: number) => {
if (prevReadyTimeoutRef.current !== null) {
window.clearTimeout(prevReadyTimeoutRef.current)
}
prevReadyTimeoutRef.current = window.setTimeout(() => {
prevReadyTimeoutRef.current = null
setPrevState(false)
}, timeout)
}, [])

return {
state: state || prevState,
setState: setStateAndClearResets,
resetState: resetStateAfterDelay,
}
}

/**
* A Meteor Subscription hook that allows using React Functional Components and the Hooks API with Meteor subscriptions.
* Subscriptions will be torn down 1000ms after unmounting the component.
Expand All @@ -383,20 +440,28 @@ export function useSubscription<K extends keyof AllPubSubTypes>(
sub: K,
...args: Parameters<AllPubSubTypes[K]>
): boolean {
const [ready, setReady] = useState<boolean>(false)
const { state: ready, setState: setReady, resetState: cancelPreviousReady } = useDelayState()

useEffect(() => {
const subscription = Tracker.nonreactive(() => meteorSubscribe(sub, ...args))
const isReadyComp = Tracker.nonreactive(() => Tracker.autorun(() => setReady(subscription.ready())))
const isReadyComp = Tracker.nonreactive(() =>
Tracker.autorun(() => {
const isNowReady = subscription.ready()
setReady(isNowReady)
})
)
return () => {
isReadyComp.stop()
setTimeout(() => {
subscription.stop()
}, 1000)
}, SUBSCRIPTION_TIMEOUT)
cancelPreviousReady(SUBSCRIPTION_TIMEOUT)
}
}, [sub, stringifyObjects(args)])

return ready
const isReady = ready

return isReady
}

/**
Expand All @@ -415,7 +480,7 @@ export function useSubscriptionIfEnabled<K extends keyof AllPubSubTypes>(
enable: boolean,
...args: Parameters<AllPubSubTypes[K]>
): boolean {
const [ready, setReady] = useState<boolean>(false)
const { state: ready, setState: setReady, resetState: cancelPreviousReady } = useDelayState()

useEffect(() => {
if (!enable) {
Expand All @@ -424,16 +489,69 @@ export function useSubscriptionIfEnabled<K extends keyof AllPubSubTypes>(
}

const subscription = Tracker.nonreactive(() => meteorSubscribe(sub, ...args))
const isReadyComp = Tracker.nonreactive(() => Tracker.autorun(() => setReady(subscription.ready())))
const isReadyComp = Tracker.nonreactive(() =>
Tracker.autorun(() => {
const isNowReady = subscription.ready()
setReady(isNowReady)
})
)
return () => {
isReadyComp.stop()
setTimeout(() => {
subscription.stop()
}, 1000)
}, SUBSCRIPTION_TIMEOUT)
cancelPreviousReady(SUBSCRIPTION_TIMEOUT)
}
}, [sub, enable, stringifyObjects(args)])

return !enable || ready
const isReady = !enable || ready

return isReady
}

/**
* A Meteor Subscription hook that allows using React Functional Components and the Hooks API with Meteor subscriptions.
* Subscriptions will be torn down 1000ms after unmounting the component.
* If the subscription is not enabled, the subscription will not be created, and the ready state will always be true.
*
* @export
* @param {PubSub} sub The subscription to be subscribed to
* @param {boolean} enable Whether the subscription is enabled
* @param {...any[]} args A list of arugments for the subscription. This is used for optimizing the subscription across
* renders so that it isn't torn down and created for every render.
*/
export function useSubscriptionIfEnabledReadyOnce<K extends keyof AllPubSubTypes>(
sub: K,
enable: boolean,
...args: Parameters<AllPubSubTypes[K]>
): boolean {
const { state: ready, setState: setReady, resetState: cancelPreviousReady } = useDelayState()

useEffect(() => {
if (!enable) {
setReady(false)
return
}

const subscription = Tracker.nonreactive(() => meteorSubscribe(sub, ...args))
const isReadyComp = Tracker.nonreactive(() =>
Tracker.autorun(() => {
const isNowReady = subscription.ready()
if (isNowReady) setReady(true)
})
)
return () => {
isReadyComp.stop()
setTimeout(() => {
subscription.stop()
}, SUBSCRIPTION_TIMEOUT)
cancelPreviousReady(SUBSCRIPTION_TIMEOUT)
}
}, [sub, enable, stringifyObjects(args)])

const isReady = !enable || ready

return isReady
}

/**
Expand Down
Loading

0 comments on commit 96993d0

Please sign in to comment.