-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
141 lines (127 loc) · 5.36 KB
/
update-dev-beta-browser-images.yml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Update Dev/Beta Browser Images
on:
workflow_dispatch:
inputs:
rerunFailedOnly:
description: 'Rerun only failed jobs'
required: false
type: boolean
default: true
schedule:
# Trigger build every 2 days
- cron: '0 2 */2 * *'
permissions: write-all
env:
GH_CLI_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_CLI_TOKEN_PR: ${{ secrets.SELENIUM_CI_TOKEN || secrets.GITHUB_TOKEN }}
RUN_ID: ${{ github.run_id }}
RERUN_FAILED_ONLY: ${{ github.event.inputs.rerunFailedOnly || true }}
RUN_ATTEMPT: ${{ github.run_attempt }}
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: [chrome,firefox,edge]
channel: [dev,beta]
env:
NAME: ${{ vars.DOCKER_NAMESPACE || 'selenium' }}
BROWSER: ${{ matrix.browser }}
CHANNEL: ${{ matrix.channel }}
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Set up containerd image store feature
uses: nick-invision/retry@master
with:
timeout_minutes: 10
max_attempts: 3
command: |
make setup_dev_env
- name: Setup environment variables
run: |
export SELENIUM_VERSION=$(grep BASE_VERSION Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)
export BINDING_VERSION=$(grep BINDING_VERSION Makefile | sed 's/.*,\([^)]*\))/\1/p' | head -n 1)
echo "SELENIUM_VERSION="$SELENIUM_VERSION >> $GITHUB_ENV
echo "BINDING_VERSION="$BINDING_VERSION >> $GITHUB_ENV
export BUILD_DATE=$(date '+%Y%m%d')
echo "BUILD_DATE="$BUILD_DATE >> $GITHUB_ENV
export BROWSER_CAPS=`node -p "process.argv[1][0].toUpperCase() + process.argv[1].toString().substring(1)" $BROWSER`
echo "BROWSER_CAPS="$BROWSER_CAPS >> $GITHUB_ENV
export CHANNEL_CAPS=`node -p "process.argv[1][0].toUpperCase() + process.argv[1].toString().substring(1)" $CHANNEL`
echo "CHANNEL_CAPS="$CHANNEL_CAPS >> $GITHUB_ENV
echo "BROWSER is $BROWSER"
echo "CHANNEL is $CHANNEL"
echo "SELENIUM_VERSION is $SELENIUM_VERSION"
echo "BUILD_DATE is $BUILD_DATE"
- name: Pull hub and node-base and tag them for faster building and testing
run: |
docker pull $NAME/hub:latest
docker pull $NAME/node-base:latest
docker tag $NAME/hub:latest $NAME/hub:$CHANNEL
docker tag $NAME/node-base:latest $NAME/node-base:$CHANNEL
docker tag $NAME/hub:latest $NAME/hub:"$SELENIUM_VERSION"-"$BUILD_DATE"
docker tag $NAME/node-base:latest $NAME/node-base:"$SELENIUM_VERSION"-"$BUILD_DATE"
- name: Build the Dev/Beta Docker container images
run: |
echo VERSION=$SELENIUM_VERSION make "$BROWSER"_"$CHANNEL" standalone_"$BROWSER"_"$CHANNEL"
VERSION=$SELENIUM_VERSION make "$BROWSER"_"$CHANNEL" standalone_"$BROWSER"_"$CHANNEL"
- name: Test the Dev/Beta Docker container images
run: |
export SKIP_BUILD=true
export NAMESPACE=$NAME
VERSION=$CHANNEL ./tests/bootstrap.sh Node$BROWSER_CAPS
VERSION=$CHANNEL ./tests/bootstrap.sh Standalone$BROWSER_CAPS
- name: Login Docker Hub
run: docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
- name: Deploy Dev/Beta Docker container images
run: |
docker push $NAME/node-$BROWSER:$CHANNEL
docker push $NAME/standalone-$BROWSER:$CHANNEL
if [ "$BROWSER" = "firefox" ]; then
export DRIVER_VERSION_COMMAND="/usr/bin/geckodriver --version | head -n 1"
export BROWSER_VERSION_COMMAND="firefox -version"
elif [ "$BROWSER" = "chrome" ]; then
export DRIVER_VERSION_COMMAND="/usr/bin/chromedriver -version"
export BROWSER_VERSION_COMMAND="google-chrome -version"
elif [ "$BROWSER" = "edge" ]; then
export DRIVER_VERSION_COMMAND="/usr/bin/msedgedriver -version"
export BROWSER_VERSION_COMMAND="microsoft-edge -version"
fi
echo "Push to Docker Hub completed"
echo "$BROWSER_CAPS $CHANNEL_CAPS browser version:"
docker run --rm $NAME/standalone-$BROWSER:$CHANNEL bash -c "$BROWSER_VERSION_COMMAND"
echo "$BROWSER_CAPS $CHANNEL_CAPS WebDriver version:"
docker run --rm $NAME/standalone-$BROWSER:$CHANNEL bash -c "$DRIVER_VERSION_COMMAND"
rerun-workflow-when-failure:
name: Rerun workflow when failure
needs:
- deploy
if: failure() && ( github.run_attempt < 3 )
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Install GitHub CLI
run: |
sudo apt update
sudo apt install gh
- name: Authenticate GitHub CLI for PR
if: github.event_name == 'pull_request'
run: |
echo "$GH_CLI_TOKEN_PR" | gh auth login --with-token
- name: Authenticate GitHub CLI
if: github.event_name != 'pull_request'
run: |
echo "$GH_CLI_TOKEN" | gh auth login --with-token
- name: Rerun workflow when failure
run: |
echo "Rerun workflow ID $RUN_ID in attempt #$(($RUN_ATTEMPT + 1))"
gh workflow run rerun-failed.yml \
--repo $GITHUB_REPOSITORY \
--raw-field runId=$RUN_ID \
--raw-field rerunFailedOnly=$RERUN_FAILED_ONLY