Skip to content

Commit

Permalink
Fix missing contexts, reuse CircleCI token (#1859)
Browse files Browse the repository at this point in the history
  • Loading branch information
OdNairy committed Jan 19, 2023
1 parent fbe769a commit ff77b74
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ workflows:
- Fastlane Match
- SDK Registry Token
- Apple Machine account
- Maps SDK/Public Mapbox Token
name: Build MapboxTestHost tests
- run-tests:
context:
Expand Down Expand Up @@ -135,6 +136,7 @@ workflows:
- Fastlane Match
- SDK Registry Token
- Apple Machine account
- Maps SDK/Public Mapbox Token
name: Build MapboxTestHost tests [non-main]
requires:
- run-tests?
Expand All @@ -158,6 +160,7 @@ workflows:
- Fastlane Match
- SDK Registry Token
- Apple Machine account
- Maps SDK/Public Mapbox Token
name: Build Examples tests [non-main]
requires:
- run-examples-tests?
Expand Down Expand Up @@ -218,19 +221,23 @@ workflows:
- trigger-metrics-v2:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
- trigger-binary-size:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
requires:
- Build SDK
- trigger-metrics-build:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
requires:
- Build SDK
- trigger-metrics-collection:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
requires:
- Build SDK
filters:
Expand Down Expand Up @@ -288,6 +295,7 @@ workflows:
- Fastlane Match
- SDK Registry Token
- Apple Machine account
- Maps SDK/Public Mapbox Token
name: Build MapboxTestHost tests
- run-tests:
context:
Expand All @@ -309,6 +317,7 @@ workflows:
- Fastlane Match
- SDK Registry Token
- Apple Machine account
- Maps SDK/Public Mapbox Token
name: Build Examples tests
- run-tests:
context:
Expand All @@ -325,6 +334,7 @@ workflows:
- trigger-internal-ci-sync:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
filters:
branches:
only:
Expand All @@ -335,6 +345,7 @@ workflows:
- sdk-e2e-test:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
filters:
branches:
ignore:
Expand All @@ -343,6 +354,7 @@ workflows:
- sdk-e2e-test:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
filters:
branches:
only:
Expand All @@ -363,6 +375,7 @@ workflows:
- trigger-metrics-v2:
context:
- Slack Orb
- Maps SDK/CircleCI API Token
<<: *release-anchor
- build-baseline-sdk:
context:
Expand Down Expand Up @@ -583,14 +596,14 @@ jobs:
- run:
name: Trigger binary size test
command: |
if [ -n "${CIRCLECI_API_TOKEN_MOBILE_METRICS}" ]; then
if [ -n "${CIRCLECI_API_TOKEN}" ]; then
if [[ $CIRCLE_BRANCH == main ]]; then
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-binary-size\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN_MOBILE_METRICS}
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-binary-size\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN}
else
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-binary-size\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\",\"SOURCE_COMPARE_BASELINE\":\"YES\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN_MOBILE_METRICS}
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-binary-size\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\",\"SOURCE_COMPARE_BASELINE\":\"YES\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN}
fi
else
echo "CIRCLECI_API_TOKEN_MOBILE_METRICS not provided"
echo "CIRCLECI_API_TOKEN not provided"
fi
trigger-metrics-build:
Expand All @@ -599,18 +612,18 @@ jobs:
- run:
name: Build metrics tests
command: |
if [ -n "${CIRCLECI_API_TOKEN_MOBILE_METRICS}" ]; then
if [ -n "${CIRCLECI_API_TOKEN}" ]; then
if [[ $CIRCLE_BRANCH == main ]]; then
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-build\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN_MOBILE_METRICS}
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-build\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN}
else
echo "Trying $CIRCLE_BRANCH first:"
if ! curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-build\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/$CIRCLE_BRANCH?circle-token=${CIRCLECI_API_TOKEN_MOBILE_METRICS}; then
if ! curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-build\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/$CIRCLE_BRANCH?circle-token=${CIRCLECI_API_TOKEN}; then
echo "Falling back to `master` branch:"
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-build\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN_MOBILE_METRICS}
curl --fail -X POST --header "Content-Type: application/json" --data "{\"build_parameters\":{\"CIRCLE_JOB\":\"ios-maps-v10-build\",\"SOURCE_HASH\":\"${CIRCLE_SHA1}\",\"SOURCE_NAME\":\"ios-maps-v10\"}}" https://circleci.com/api/v1.1/project/github/mapbox/mobile-metrics/tree/master?circle-token=${CIRCLECI_API_TOKEN}
fi
fi
else
echo "CIRCLECI_API_TOKEN_MOBILE_METRICS not provided"
echo "CIRCLECI_API_TOKEN not provided"
fi
trigger-metrics-v2:
Expand All @@ -628,7 +641,7 @@ jobs:
curl -X POST "https://circleci.com/api/v2/project/github/mapbox/mapbox-maps-ios-internal/pipeline" \
-H 'Content-Type: application/json' \
-H "Circle-Token: $CIRCLECI_API_TOKEN_MAPBOX_MAPS_IOS_INTERNAL" \
-H "Circle-Token: $CIRCLECI_API_TOKEN" \
-d $'{
"branch": "main",
"parameters": {
Expand All @@ -648,10 +661,10 @@ jobs:
# TODO: main by default (this is set as a filter), other commits on-demand
name: Trigger metrics
command: |
if [ -n "${CIRCLECI_API_TOKEN_MOBILE_METRICS}" ]; then
curl --fail -X POST --header "Content-Type: application/json" --data "{\"parameters\":{\"run_ios_maps_v10_benchmark\":true,\"ci_ref\":${CIRCLE_BUILD_NUM},\"mapbox_hash\":\"${CIRCLE_SHA1}\",\"target_branch\":\"${CIRCLE_BRANCH}\"},\"branch\":\"master\"}" https://circleci.com/api/v2/project/github/mapbox/mobile-metrics/pipeline?circle-token=${CIRCLECI_API_TOKEN_MOBILE_METRICS}
if [ -n "${CIRCLECI_API_TOKEN}" ]; then
curl --fail -X POST --header "Content-Type: application/json" --data "{\"parameters\":{\"run_ios_maps_v10_benchmark\":true,\"ci_ref\":${CIRCLE_BUILD_NUM},\"mapbox_hash\":\"${CIRCLE_SHA1}\",\"target_branch\":\"${CIRCLE_BRANCH}\"},\"branch\":\"master\"}" https://circleci.com/api/v2/project/github/mapbox/mobile-metrics/pipeline?circle-token=${CIRCLECI_API_TOKEN}
else
echo "CIRCLECI_API_TOKEN_MOBILE_METRICS not provided"
echo "CIRCLECI_API_TOKEN not provided"
fi
- report-failure:
report_failure: << parameters.report_failure >>
Expand All @@ -676,7 +689,7 @@ jobs:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update && sudo apt install gh -y
sudo pip3 install gitpython
echo "export CIRCLE_API_TOKEN=$CIRCLECI_API_TOKEN_MAPBOX_MAPS_IOS_INTERNAL" >> $BASH_ENV
echo "export CIRCLE_API_TOKEN=$CIRCLECI_API_TOKEN" >> $BASH_ENV
source $BASH_ENV
name: Install dependency
- when:
Expand Down Expand Up @@ -1308,7 +1321,7 @@ jobs:
command: |
curl -X POST "https://circleci.com/api/v2/project/github/mapbox/mapbox-maps-ios-private/pipeline" \
-H 'Content-Type: application/json' \
-H "Circle-Token: $CIRCLECI_API_TOKEN_MAPBOX_MAPS_IOS_INTERNAL" \
-H "Circle-Token: $CIRCLECI_API_TOKEN" \
-d $'{
"branch": "internal",
"parameters": {
Expand Down

0 comments on commit ff77b74

Please sign in to comment.