Skip to content

Commit

Permalink
Merge branch 'main' of github.com:AudiusProject/audius-protocol into …
Browse files Browse the repository at this point in the history
…jd/harmony-text-input
  • Loading branch information
DejayJD committed Oct 19, 2023
2 parents c2f7545 + 785a815 commit c2e295b
Show file tree
Hide file tree
Showing 107 changed files with 1,928 additions and 602 deletions.
82 changes: 4 additions & 78 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,7 @@ jobs:
- ./packages/libs/node_modules
- ./packages/identity-service/node_modules

- save_cache:
key: cache-{{ .Revision }}
paths:
- ./packages/stems/dist
- ./packages/harmony/dist
- ./packages/common/dist
- ./packages/libs/dist
- ./packages/spl/dist

generate-release:
generate-release-branch:
working_directory: ~/audius-protocol
resource_class: small
docker:
Expand All @@ -106,7 +97,7 @@ jobs:
git config --global user.email "audius-infra@audius.co"
git config --global user.name "audius-infra"
- run:
name: Create branch
name: Create + push branch
command: |
git checkout main
Expand All @@ -121,75 +112,11 @@ jobs:
mv /tmp/.version.json packages/discovery-provider/.version.json
git add packages/discovery-provider/.version.json
GIT_DIFF=$(git log --pretty=format:'%an - %s [<https://github.com/AudiusProject/audius-protocol/commit/%H|%h>]' --abbrev-commit origin/release-v$OLD_VERSION..HEAD -- mediorum packages/discovery-provider packages/identity-service comms monitoring/healthz | sed 's/"/\\"/g' | tr -d '\r' | sed ':a;N;$!ba;s/\n/=DELIM@/g')
# Ensure GIT_DIFF ends with the delimiter so the final commit is included
if [ ! -z "$GIT_DIFF" ] && [ "${GIT_DIFF: -7}" != "=DELIM@" ]; then
GIT_DIFF="${GIT_DIFF}=DELIM@"
fi
echo "GIT_DIFF: $GIT_DIFF"
git commit -m "Bump version to $NEW_VERSION"
git branch "release-v$NEW_VERSION"
git checkout "release-v$NEW_VERSION"
git push --set-upstream origin main "release-v$NEW_VERSION"
# Slack has a limit of 3000 characters per block, so we need to split the diff into multiple blocks
max_lines=8
json_content="{ \"blocks\": ["
json_content+="{ \"type\": \"header\", \"text\": { \"type\": \"plain_text\", \"text\": \"New Protocol Release Branch (v$NEW_VERSION)\n\" } },"
line_count=0
block_content=""
# Use =DELIM@ as a delimiter to split the diff into lines (so set Internal Field Separator to "@")
buffer=""
IFS="@"
read -ra ADDR \<<< "$GIT_DIFF"
for line in "${ADDR[@]}"; do
line="${buffer}${line}"
# If the current line ends with "=DELIM", then it's a complete line, so process it and reset buffer
if [ "${line: -6}" = "=DELIM" ]; then
line="${line%=DELIM}"
buffer=""
# Try to replace the author with a Slack mention (use author's name without hyphens or spaces because sh env doesn't allow that)
author_name=$(echo "$line" | awk -F ' - ' '{print $1}')
env_key_name="SLACK_ID_FOR_GH_$(echo $author_name | tr ' ' '_' | tr '-' '_' | tr '[:upper:]' '[:lower:]')"
env_var_value=$(eval echo \$$env_key_name)
if [ ! -z "$env_var_value" ]; then
line=$(echo "$line" | sed "s/$author_name/<@$env_var_value>/")
fi
block_content+="• $line\n"
line_count=$((line_count+1))
if (( line_count == max_lines )); then
json_content+="{ \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"${block_content}\" } },"
line_count=0
block_content=""
fi
else
# Otherwise, store the current line in the buffer and wait for the next iteration
buffer+="${line}@"
fi
done
if (( line_count > 0 )); then
json_content+="{ \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"${block_content}\" } },"
fi
json_content+="{ \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"\n*These changes will be auto-deployed to foundation nodes in 3 hours (11am PST).* Set \`HALT_AUTO_DEPLOY\`=\`true\` <https://app.circleci.com/settings/organization/github/AudiusProject/contexts/4be7f5c8-cadb-4deb-b66e-318867a6960b|here> if needed.\n\" } }"
json_content+="]}"
# Send Slack daily deploy message
echo "Sending message to Slack: $json_content"
curl -f -X POST -H 'Content-type: application/json' \
--data "$json_content" \
$SLACK_DAILY_DEPLOY_WEBHOOK
approve-deployment-holds:
resource_class: small
docker:
Expand Down Expand Up @@ -271,7 +198,7 @@ jobs:
if [[ -z "$job_url" ]]; then
# If we couldn't find the deploy trigger job on hold, send the failure message
json_content+="{ \"type\": \"section\","
json_content+=" \"text\": { \"type\": \"mrkdwn\", \"text\": \"I tried to deploy today's release to foundation nodes but have failed miserably :( please investigate\" } }"
json_content+=" \"text\": { \"type\": \"mrkdwn\", \"text\": \"No CircleCI job is on hold for me to auto-approve for today's foundation release (hint: check <https://app.circleci.com/pipelines/github/AudiusProject/audius-protocol?branch=$CIRCLE_BRANCH|here>)\" } }"
else
# If we approved the job, send the success message
json_content+="{ \"type\": \"section\","
Expand Down Expand Up @@ -554,8 +481,7 @@ workflows:
- equal: [scheduled_pipeline, << pipeline.trigger_source >>]
- equal: ['release-create-branch', << pipeline.schedule.name >>]
jobs:
- generate-release:
context: slack-secrets
- generate-release-branch

auto-approve-foundation-deploy:
when:
Expand Down
57 changes: 57 additions & 0 deletions .circleci/scripts/circleci-startup-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/env bash
set -ex

# See https://circleci.com/docs/runner-installation-linux/
# Self-hosted runners should link to this file as the startup script.

apt install -y git coreutils curl

# download and run circleci agent installer script
curl -L https://raw.githubusercontent.com/CircleCI-Public/runner-installation-files/main/download-launch-agent.sh -o download-launch-agent.sh
export platform=linux/amd64 && sh ./download-launch-agent.sh
rm download-launch-agent.sh

# setup user and dirs
id -u circleci &>/dev/null || adduser --disabled-password --gecos GECOS circleci
groupadd -f docker
usermod -aG docker circleci
mkdir -p /var/opt/circleci
chmod 0750 /var/opt/circleci
chown -R circleci /var/opt/circleci /opt/circleci

# setup config
mkdir -p /etc/opt/circleci && touch /etc/opt/circleci/launch-agent-config.yaml
chown -R circleci: /etc/opt/circleci
chmod 600 /etc/opt/circleci/launch-agent-config.yaml
cat <<EOT >> /etc/opt/circleci/launch-agent-config.yaml
api:
auth_token: $(gcloud secrets versions access 1 --secret=circleci-auth-token)
runner:
name: $(hostname)
working_directory: /var/opt/circleci/workdir
cleanup_working_directory: true
EOT

# allow sudo
echo "circleci ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers

# enable circleci systemd service
touch /usr/lib/systemd/system/circleci.service
chown root: /usr/lib/systemd/system/circleci.service
chmod 755 /usr/lib/systemd/system/circleci.service
cat <<EOT >> /usr/lib/systemd/system/circleci.service
[Unit]
Description=CircleCI Runner
After=network.target
[Service]
ExecStart=/opt/circleci/circleci-launch-agent --config /etc/opt/circleci/launch-agent-config.yaml
Restart=always
User=circleci
NotifyAccess=exec
TimeoutStopSec=18300
[Install]
WantedBy = multi-user.target
EOT
systemctl enable circleci.service
systemctl start circleci.service
10 changes: 4 additions & 6 deletions .circleci/src/commands/@common-commands.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
common-lint:
description: "lint @audius/common"
description: 'lint @audius/common'
steps:
- run:
name: "lint @audius/common"
command: |
cd packages/common
npm run lint
- run:
name: 'lint @audius/common'
command: npx turbo run lint --filter=@audius/common
11 changes: 10 additions & 1 deletion .circleci/src/commands/@mobile-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ mobile-prepare-ios:
command: |
curl -sL https://sentry.io/get-cli/ | bash
echo export SENTRY_BINARY=/usr/local/bin/sentry-cli >> "$BASH_ENV"
- run:
name: Build dependencies
command: npx turbo run build --filter=audius-mobile-client
- run:
name: create bundle
command: cd packages/mobile && npm run bundle:ios
command: cd packages/mobile && npx turbo run bundle:ios
- run:
name: update fastlane
command: cd packages/mobile/ios && sudo bundle update fastlane
Expand Down Expand Up @@ -142,6 +145,9 @@ mobile-prepare-android:
- run:
name: update fastlane
command: cd packages/mobile/android && sudo bundle update fastlane
- run:
name: Build dependencies
command: npx turbo run build --filter=audius-mobile-client
- run:
name: fetch app fastlane json config to upload to play store
command: |
Expand Down Expand Up @@ -230,6 +236,9 @@ mobile-release-saga-dapp-store:
corepack enable --install-directory ~/bin
corepack prepare pnpm@`npm info pnpm --json | jq -r .version` --activate
pnpm install
- run:
name: Build dependencies
command: npx turbo run build --filter=audius-mobile-client
- run:
name: Install solana
command: |
Expand Down
4 changes: 0 additions & 4 deletions .circleci/src/jobs/@embed-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ embed-init:
keys:
- cache-{{ checksum "package-lock.json" }}-{{ checksum "combined-patch-file.txt" }}

- restore_cache:
keys:
- cache-{{ .Revision }}

- persist_to_workspace:
root: ./
paths:
Expand Down
4 changes: 0 additions & 4 deletions .circleci/src/jobs/@identity-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ identity-init:
keys:
- cache-{{ checksum "package-lock.json" }}-{{ checksum "combined-patch-file.txt" }}

- restore_cache:
keys:
- cache-{{ .Revision }}

- run:
name: verify
command: npx turbo run verify --filter=identity-service
Expand Down
9 changes: 3 additions & 6 deletions .circleci/src/jobs/@mobile-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ mobile-init:
- common-lint

- run:
name: typecheck
command: cd packages/mobile && npm run typecheck

- run:
name: lint
command: cd packages/mobile && npm run lint
name: lint & typecheck
command: |
npx turbo run verify --filter=audius-mobile-client
- persist_to_workspace:
root: ./
Expand Down
20 changes: 4 additions & 16 deletions .circleci/src/jobs/@web-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,17 @@ web-init:
keys:
- cache-{{ checksum "package-lock.json" }}-{{ checksum "combined-patch-file.txt" }}

- restore_cache:
keys:
- cache-{{ .Revision }}

- common-lint

- run:
name: typecheck
name: lint & typecheck
command: |
cd packages/web
npm run typecheck
- run:
name: lint
command: |
cd packages/web
npm run lint
npx turbo run verify --filter=audius-client
- run:
name: stylelint
command: |
cd packages/web
npm run stylelint
npm run stylelint -w audius-client
- persist_to_workspace:
root: ./
Expand Down Expand Up @@ -70,7 +58,7 @@ web-build-demo:
command: |
cd packages/web
export PUBLIC_URL=/${CIRCLE_BRANCH}
CI=false npm run build:stage
CI=false npm run build:stage -w audius-client
mv build-staging build-demo
- persist_to_workspace:
root: ./
Expand Down
Loading

0 comments on commit c2e295b

Please sign in to comment.