File: epochs_update.sh

package info (click to toggle)
thunderbird 1%3A140.5.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,609,032 kB
  • sloc: cpp: 7,672,739; javascript: 5,901,898; ansic: 3,898,899; python: 1,413,347; xml: 653,997; asm: 462,284; java: 180,927; sh: 113,491; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (58 lines) | stat: -rwxr-xr-x 1,647 bytes parent folder | download | duplicates (10)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -eux -o pipefail

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

EPOCHS=(
epochs/three_hourly::3h
epochs/six_hourly::6h
epochs/twelve_hourly::12h
epochs/daily::1d
epochs/weekly::1w
)

function get_epoch_branch_name () {
    echo ${1} | awk -F '::' '{print $1}'
}

function get_epoch_timeval () {
    echo ${1} | awk -F '::' '{print $2}'
}

main () {
    ALL_BRANCHES_NAMES=""
    for e in "${EPOCHS[@]}";
    do
        EPOCH=$(get_epoch_timeval ${e})
        EPOCH_BRANCH_NAME=$(get_epoch_branch_name ${e})
        EPOCH_SHA=$(./wpt rev-list --epoch ${EPOCH})
        if [ "${EPOCH_SHA}" = "" ]; then
            echo "ERROR: Empty SHA returned from ./wpt rev-list"
            exit 1
        fi
        git branch "${EPOCH_BRANCH_NAME}" "${EPOCH_SHA}"

        # Only set epoch tag if is not already tagged from a previous run.
        if ! git tag --points-at "${EPOCH_SHA}" | grep "${EPOCH_BRANCH_NAME}"; then
            EPOCH_STAMP="$(date +%Y-%m-%d_%HH)"
            git tag "${EPOCH_BRANCH_NAME}/${EPOCH_STAMP}" "${EPOCH_SHA}"
        fi

        ALL_BRANCHES_NAMES="${ALL_BRANCHES_NAMES} ${EPOCH_BRANCH_NAME}"
    done
    # This is safe because `git push` will by default fail for a non-fast-forward
    # push, for example if the remote branch is ahead of the local branch.
    git push --porcelain --tags ${REMOTE} ${ALL_BRANCHES_NAMES} | tee "${RUNNER_TEMP}/git-push-output.txt"
}

cd $WPT_ROOT

if [ -z "$GITHUB_TOKEN" ]; then
    echo "GITHUB_TOKEN must be set as an environment variable"
    exit 1
fi

REMOTE=https://x-access-token:$GITHUB_TOKEN@github.com/web-platform-tests/wpt.git

main