This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run unit & integration tests against Golang RC version | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
name: RC version check | |
runs-on: ubuntu-latest | |
# env: | |
# # COSMOS_CONNECTION_URL: ${{ secrets.COSMOS_CONNECTION_URL }} | |
# # COSMOS_KEY: ${{ secrets.COSMOS_KEY }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Run coverage commands | |
shell: bash | |
id: run_tests_with_rc | |
continue-on-error: true | |
run: | | |
#!/bin/bash | |
shopt -s expand_aliases | |
TRACER_PATH=$(pwd) | |
echo $TRACER_PATH | |
echo "Dealing with Golang RC version!" | |
rcToInstall=$(git ls-remote -t https://github.com/golang/go | awk -F/ '{ print $NF }' | sort -V | grep rc | tail -1 | tr -d ' ') | |
echo "RC version : $rcToInstall" | |
url="golang.org/dl/$rcToInstall@latest" | |
echo "RC URL : $url" | |
go install $url | |
ls ~/go | |
ls ~/go/bin | |
# which go1.23rc2 | |
alias gorc="~/go/bin/$rcToInstall" | |
gorc download | |
gorc version | |
echo "Starting Couchbase" | |
docker compose -f docker-compose-integration.yaml up -d | |
echo "Starting Postgres" | |
sudo systemctl start postgresql.service | |
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'mysecretpassword'" | |
echo "After starting Postgres" | |
echo "Running unit test on core." | |
gorc1 test -v -coverpkg=./... -cover -covermode atomic ./... | |
DEPRECATED_PKGS=".*instaamqp$" | |
LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS") | |
for lib in $LIB_LIST | |
do echo "Running unit test for $lib" && cd "$lib" && gorc mod tidy && gorc test -v -coverpkg=./... -cover -covermode atomic ./... && cd -; | |
done | |
INTEGRATIONS_TESTS=("instagocb" "instapgx" "instapgx/v2") | |
for str in ${INTEGRATIONS_TESTS[@]}; do | |
dir=./instrumentation/$str | |
echo "Running unit test for $dir" | |
cd $dir | |
gorc mod tidy | |
gorc test -v -tags=integration -coverpkg=./... -cover -covermode atomic ./... && cd - | |
done | |
echo "All done!" | |
echo "GO_RC_VERSION=$rcToInstall" >> $GITHUB_ENV | |
- name: Send sucess to slack channel | |
if: ${{ steps.run_tests_with_rc.outcome == 'success'}} | |
uses: slackapi/slack-github-action@v1.24.0 | |
with: | |
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }} | |
payload: | | |
{ | |
"text": ":mega: Unit tests executed successfully with Golang RC version ${{ env.GO_RC_VERSION }}. :tada:", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": ":mega: Unit tests executed successfully with Golang RC version ${{ env.GO_RC_VERSION }}. :tada:" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
SLACK_RELEASE_CHANNEL_ID: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }} | |
- name: Send sucess to slack channel | |
if: ${{ steps.run_tests_with_rc.outcome == 'failure'}} | |
uses: slackapi/slack-github-action@v1.24.0 | |
with: | |
channel-id: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }} | |
payload: | | |
{ | |
"text": ":alert2: Unit tests run with Golang RC version ${{ env.GO_RC_VERSION }} have failed! :alert2:", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": ":alert2: Unit tests run with Golang RC version ${{ env.GO_RC_VERSION }} have failed! :alert2:" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
SLACK_RELEASE_CHANNEL_ID: ${{ secrets.SLACK_RELEASE_CHANNEL_ID }} | |