summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/ci/interfaces_update.sh
blob: 6bf7c7c7128574d50c3f250911ed3042b5516058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -eux -o pipefail

SCRIPT_DIR=$(cd $(dirname "$0") && pwd -P)
WPT_ROOT=$SCRIPT_DIR/../..

main () {
    # Find the latest version of the package to install.
    VERSION=$(npm info @webref/idl version)

    # Install @webref/idl in a temporary directory.
    TMPDIR=$(mktemp -d)
    cd $TMPDIR
    npm install @webref/idl@$VERSION

    # Delete interfaces/*.idl except tentative ones
    cd $WPT_ROOT
    find interfaces/ -name '*.idl' -not -name '*.tentative.idl' -delete

    # Handle cssom.idl with preamble first.
    cat <<EOF > interfaces/cssom.idl
// GENERATED PREAMBLE - DO NOT EDIT
// CSSOMString is an implementation-defined type of either DOMString or
// USVString in CSSOM: https://drafts.csswg.org/cssom/#cssomstring-type
// For web-platform-tests, use DOMString because USVString has additional
// requirements in type conversion and could result in spurious failures for
// implementations that use DOMString.
typedef DOMString CSSOMString;

EOF
    cat $TMPDIR/node_modules/@webref/idl/cssom.idl >> interfaces/cssom.idl
    rm $TMPDIR/node_modules/@webref/idl/cssom.idl

    # Move remaining *.idl from @webref/idl to interfaces/
    mv $TMPDIR/node_modules/@webref/idl/*.idl interfaces/

    # Cleanup
    rm -rf $TMPDIR

    if [ -n "$GITHUB_ENV" ]; then
        echo webref_idl_version=$VERSION >> $GITHUB_ENV
    fi
}

main