mirrored from https://bitbucket.org/bing-rewards/bing-rewards/
-
Notifications
You must be signed in to change notification settings - Fork 17
/
bitbucket-pipelines.yml
49 lines (45 loc) · 2.08 KB
/
bitbucket-pipelines.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
options:
docker: true
pipelines:
tags:
'*':
- step:
name: Build and push Docker image on new git tag
image: atlassian/default-image:4
script:
- export DOCKER_HUB_REPO=jwong235/bing-rewards
- export IMAGE_TAG=$DOCKER_HUB_REPO:$BITBUCKET_TAG
- export IMAGE_TAG_LATEST=$DOCKER_HUB_REPO:latest
- docker login -u jwong235 -p $DOCKER_PASSWORD
- docker build -t $IMAGE_TAG -t $IMAGE_TAG_LATEST .
- docker push $IMAGE_TAG
- >
if [[ ${BITBUCKET_TAG} =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
docker push $IMAGE_TAG_LATEST
fi
pull-requests:
'**':
- step:
image: python:3.9.13-slim
caches:
- pip
script:
- pip install flake8 black
- apt-get update && apt-get install -y git
- git fetch origin "+refs/heads/$BITBUCKET_PR_DESTINATION_BRANCH:refs/remotes/origin/$BITBUCKET_PR_DESTINATION_BRANCH"
- export python_file_diff=$(git diff --name-only origin/$BITBUCKET_PR_DESTINATION_BRANCH... | grep '\.py$')
- echo -e "Changed python files:\n$(echo $python_file_diff | tr ' ' '\n')"
- if [ -n "$python_file_diff" ]; then echo $python_file_diff | xargs flake8 --config=.flake8; fi
- if [ -n "$python_file_diff" ]; then echo $python_file_diff | xargs black --check; fi
- step:
image: jwong235/bing-rewards:latest
script:
- apt-get update && apt-get install -y jq
- cd ..
- python build/BingRewards/setup.py -e $MS_TEST_ACCOUNT -p $MS_TEST_PASSWORD
- python build/BingRewards/BingRewards.py -nsb -m
- log_output=$(jq -r --arg MS_TEST_ACCOUNT "$MS_TEST_ACCOUNT" '.[$MS_TEST_ACCOUNT] | .[-1]' build/BingRewards/logs/run.json)
- echo "$log_output"
# Test if program can be started, i.e log was written
# It's not possible to test this futher because we can't enter the confirmation code
- if [[ "$log_output" == *"Failed Edge Search"* ]]; then exit 0; else exit 1; fi