Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run separate build, test, and deploy workflows #2925

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 13 additions & 227 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build-Test-Deploy
name: Build

# === Triggers ===
"on":
'on':
push:
branches:
- master
Expand All @@ -20,7 +20,7 @@ name: Build-Test-Deploy
# === Workflow Permissions ===
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
contents: read # This is required for actions/checkout

# === Workflow-level environment variables ===
env:
Expand All @@ -29,7 +29,6 @@ env:

# === JOBS ===
jobs:

# === OS Specific Job (runs on each OS) ===
os_specific:
name: ${{ matrix.sys.os }}
Expand All @@ -39,9 +38,9 @@ jobs:
go-version:
- 1.20.x
sys:
- {os: ubuntu-20.04}
- {os: macos-11, shell: zsh}
- {os: windows-2019}
- { os: ubuntu-20.04 }
- { os: macos-11, shell: zsh }
- { os: windows-2019 }
fail-fast: false
runs-on: ${{ matrix.sys.os }}
env:
Expand Down Expand Up @@ -169,40 +168,33 @@ jobs:
JIRA_USERNAME: ${{ secrets.JIRA_EMAIL }}
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}

- # === Unit Tests ===
name: Unit Tests
id: unit_tests
shell: bash
run: parallelize results Unit-Tests | gotestfmt -hide empty-packages
continue-on-error: ${{ github.event_name != 'schedule' }}

- # === "Build: CLI" ===
name: "Build: CLI"
name: 'Build: CLI'
shell: bash
run: parallelize results Build-CLI

- # === "Build: Service" ===
name: "Build: Service"
name: 'Build: Service'
shell: bash
run: parallelize results Build-Service

- # === "Build: Installer" ===
name: "Build: Installer"
name: 'Build: Installer'
shell: bash
run: parallelize results Build-Installer

- # === "Build: Remote Installer" ===
name: "Build: Remote Installer"
name: 'Build: Remote Installer'
shell: bash
run: parallelize results Build-Remote-Installer

- # === "Build: Install Scripts" ===
name: "Build: Install Scripts"
name: 'Build: Install Scripts'
shell: bash
run: parallelize results Build-Install-Scripts

- # === "Build: Executor" ===
name: "Build: Executor"
name: 'Build: Executor'
shell: bash
run: parallelize results Build-Executor

Expand Down Expand Up @@ -263,7 +255,7 @@ jobs:

- # === Deploy for Integration Tests # NEVER run this against production branches. This is meant for PR deployments. ===
name: Deploy for Integration Tests # NEVER run this against production branches. This is meant for PR deployments.
if: "!contains(fromJSON('[\"refs/heads/beta\", \"refs/heads/release\", \"refs/heads/LTS\"]'), github.ref)"
if: '!contains(fromJSON(''["refs/heads/beta", "refs/heads/release", "refs/heads/LTS"]''), github.ref)'
shell: bash
run: |
if [ "$GITHUB_EVENT_NAME" != "schedule" ]; then
Expand All @@ -285,215 +277,9 @@ jobs:
state run deploy-installers
state run deploy-remote-installer

- # === Integration Tests ===
name: Integration Tests
id: integration_tests
if: "!contains(fromJSON('[\"refs/heads/beta\", \"refs/heads/release\", \"refs/heads/LTS\"]'), github.ref)"
shell: bash
run: |
if [ "$GITHUB_EVENT_NAME" != "schedule" ]; then
LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}"
IFS=',' read -r -a TESTS <<< "$LABELS"
TEST_SUITE_TAGS=""
for i in "${TESTS[@]}"; do
START=${i%:*}
if [ "$START" == "Test" ]; then
TAG=${i##*:}
TAG=$(echo $TAG | xargs)
if [[ "$TEST_SUITE_TAGS" == "" ]]; then
TEST_SUITE_TAGS=$TAG
else
TEST_SUITE_TAGS="$TAG:$TEST_SUITE_TAGS"
fi
fi
done

TARGET_BRANCH="${{ github.event.pull_request.base.ref }}"
echo "Target branch: $TARGET_BRANCH"

if [ "$TEST_SUITE_TAGS" == "" ] && [ "$TARGET_BRANCH" != "master" ] && [ "$TARGET_BRANCH" != "beta" ] && [ "$TARGET_BRANCH" != "release" ] && [ "$TARGET_BRANCH" != "lts-release" ]; then
echo "Not running because no test labels were set nor master, beta or release were targeted."
exit 0
fi
else
TEST_SUITE_TAGS="all"
fi

echo "Running integration tests with tags: $TEST_SUITE_TAGS (empty means every test not specifically tagged)"

export TEST_SUITE_TAGS="$TEST_SUITE_TAGS"
TIMEOUT=30m
if [[ "$TEST_SUITE_TAGS" == "all" ]]; then
TIMEOUT=60m
fi
SHELL='${{ matrix.sys.shell }}' go test -timeout $TIMEOUT -v `go list ./... | grep "integration"` -json 2>&1 | gotestfmt -hide empty-packages
continue-on-error: ${{ github.event_name == 'schedule' }}
env:
INTEGRATION_TEST_USERNAME: ${{ secrets.INTEGRATION_TEST_USERNAME }}
INTEGRATION_TEST_PASSWORD: ${{ secrets.INTEGRATION_TEST_PASSWORD }}
INTEGRATION_TEST_TOKEN: ${{ secrets.INTEGRATION_TEST_TOKEN }}
PLATFORM_API_TOKEN: ${{ secrets.PLATFORM_API_TOKEN }}

- # === Fail If Unscheduled Unit Tests Failed (Expand 'Unit Tests' above for more information) ===
name: Fail If Unscheduled Unit Tests Failed
if: github.event_name != 'schedule' && steps.unit_tests.outcome == 'failure'
shell: bash
run: exit 1

- # === Notify Slack of Nightly Integration Test Failures ===
name: Notify Slack of Nightly Integration Test Failures
if: github.event_name == 'schedule' && steps.integration_tests.outcome == 'failure'
uses: slackapi/[email protected]
with:
payload: |
{
"text": "Nightly integration test failure(s) on ${{ runner.os }}",
"blocks": [
{
"type": "section",
"text": {
"type": "plain_text",
"text": "Nightly integration test failure(s) on ${{ runner.os }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
},
{
"type": "section",
"text": {
"type": "plain_text",
"text": "Select the '${{ matrix.sys.os }}' job and expand 'Integration Tests' to inspect the failures."
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- # === Fail If Nightly Integration Tests Failed (Expand 'Integration Tests' above for more information) ===
name: Fail If Nightly Integration Tests Failed
if: github.event_name == 'schedule' && steps.integration_tests.outcome == 'failure'
shell: bash
run: exit 1

- # === Upload Session Artifacts ===
name: Upload Session Artifacts
uses: actions/upload-artifact@v2
with:
name: session-build-${{ matrix.sys.os }}
path: build/

# === Deploy job (runs once with combined artifacts from OS specific job) ===
deploy:
name: Deploy
needs:
- os_specific
runs-on: ubuntu-20.04
env:
ACTIVESTATE_CI: true
ACTIVESTATE_CLI_DISABLE_RUNTIME: true
SHELL: bash
GITHUB_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 10
if: contains(fromJSON('["refs/heads/master", "refs/heads/beta", "refs/heads/release", "refs/heads/LTS"]'), github.ref) || startsWith(github.event.pull_request.head.ref, 'version/')

# === Deploy Steps ===
steps:

- # === Checkout code ===
name: Checkout code
uses: actions/checkout@v2

- # === Install Go ===
name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- # === Install State Tool ===
name: Install State Tool
uses: ActiveState/setup-state-tool@v1

- # === Setup ===
name: Setup
shell: bash
run: |
bin=$(pwd)/.github/deps/${{ runner.os }}/bin
echo "Adding $bin to PATH"
echo "$bin" >> $GITHUB_PATH
ls -ahl $bin
printenv

- # === Download All Build Session Artifacts ===
name: Download All Build Session Artifacts
uses: actions/download-artifact@v2
with:
path: build/

- # === Sanitize All Session Artifacts ===
name: Sanitize All Session Artifacts
shell: bash
run: |
cd build
rm -Rf session-shared-build
find . -mindepth 2 -maxdepth 2 -print0 | xargs -0 -I file rsync -av file .
rm -Rf session*

- # === Install Deps ===
name: Install Deps
shell: bash
run: state run install-deps

- # === Preprocess ===
name: Preprocess
shell: bash
run: state run preprocess -v

- # === Cleanup Build Dir ===
name: Cleanup Build Dir
shell: bash
run: rm build/state* || true

- # === Configure AWS credentials ==
name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ env.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ env.AWS_REGION }}
mask-aws-account-id: true

- # === Generate updated master versions.json if necessary ===
name: Generate version list
shell: bash
run: state run generate-versions-list

- # === Deploy ===
name: Deploy
shell: bash
run: |
state run deploy-updates
state run deploy-installers
state run deploy-remote-installer

- # === Cleanup Session Artifacts ===
name: Cleanup Session Artifacts
uses: geekyeggo/delete-artifact@v1
with:
name: |
session-build-ubuntu-20.04
session-build-macos-11
session-build-windows-2019

- # === Upload Artifacts ===
name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: build
path: build/
Loading
Loading