test: Refactor smoke tests and add improve nightly workflow (#1566) #4
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: Integration Tests | |
on: | |
workflow_dispatch: null | |
push: | |
branches: | |
- main | |
- dev | |
jobs: | |
integration_tests: | |
name: Run integration tests | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
user: ["USER_1", "USER_2", "USER_3", "USER_4"] | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: 'recursive' | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.x' | |
- name: Install Dependencies | |
run: | | |
make deps | |
sudo apt-get update -y | |
sudo apt-get install -y build-essential | |
- name: Install go-junit-report | |
run: go install github.com/jstemmer/go-junit-report/v2@latest | |
# Note: test tags are not in alphabetical order, it was divided to optimize test execution time | |
- name: Set Test Scope for each Account | |
run: | | |
case "${{ matrix.user }}" in | |
"USER_1") | |
echo "TEST_TAGS=acceptance,backup,domain,domainrecord,domains,domainzonefile,helper,instance" >> $GITHUB_ENV | |
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_1 }}" >> $GITHUB_ENV | |
;; | |
"USER_2") | |
echo "TEST_TAGS=firewall,firewalldevice,firewalls,image,images,instancenetworking,instancesharedips,instancetype,instancetypes,ipv6range,ipv6ranges,kernel,kernels,nb,nbconfig,nbconfigs,nbnode,nbs,sshkey,sshkeys,vlan,volume,volumes,vpc,vpcs" >> $GITHUB_ENV | |
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_2 }}" >> $GITHUB_ENV | |
;; | |
"USER_3") | |
echo "TEST_TAGS=instanceconfig,instancedisk,instanceip,networkingip,objcluster,objkey,profile,rdns,region,regions,stackscript,stackscripts" >> $GITHUB_ENV | |
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_3 }}" >> $GITHUB_ENV | |
;; | |
"USER_4") | |
echo "TEST_TAGS=lke,lkeclusters,lkenodepool,lkeversions,obj,objbucket,placementgroup,placementgroups,placementgorupassignment,token,user,users" >> $GITHUB_ENV | |
echo "LINODE_TOKEN=${{ secrets.LINODE_TOKEN_USER_4 }}" >> $GITHUB_ENV | |
;; | |
esac | |
- name: Set report filename | |
run: echo "REPORT_FILENAME=$(date +'%Y%m%d%H%M')_terraform_test_report_${{ matrix.user }}.xml" >> $GITHUB_ENV | |
- name: Run Integration Tests | |
run: | | |
make TEST_TAGS="${{ env.TEST_TAGS }}" int-test | go-junit-report -set-exit-code -iocopy -out $REPORT_FILENAME | |
env: | |
LINODE_TOKEN: ${{ env.LINODE_TOKEN }} | |
- name: Upload Test Report as Artifact | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-report-${{ matrix.user }} | |
if-no-files-found: ignore | |
path: '*.xml' | |
retention-days: 1 | |
process-upload-report: | |
runs-on: ubuntu-latest | |
needs: [integration_tests] | |
if: always() && github.repository == 'linode/terraform-provider-linode' # Run even if integration tests fail and only on main repository | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: 'recursive' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Install Python dependencies | |
run: pip3 install requests wheel boto3 | |
- name: Download test report | |
uses: actions/download-artifact@v4 | |
- name: Get .xml reports from separate Artifacts into root folder | |
run: rsync -av test-report-USER_*/* . | |
- name: Merge Test Reports | |
run: python e2e_scripts/tod_scripts/xml_to_obj_storage/terraform_tests/merge_terraform_results.py | |
- name: Add Information to XML Report | |
run: | | |
filename=$(ls | grep -E '^[0-9]{12}_terraform_merged_report.xml$') | |
python e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py --branch_name "${GITHUB_REF#refs/*/}" --gha_run_id "${GITHUB_RUN_ID}" --gha_run_number "${GITHUB_RUN_NUMBER}" --xmlfile "${filename}" | |
- name: Upload Test Results | |
run: | | |
filename=$(ls | grep -E '^[0-9]{12}_terraform_merged_report.xml$') | |
python e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/xml_to_obj.py "${filename}" | |
env: | |
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }} | |
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }} | |
apply-calico-rules: | |
runs-on: ubuntu-latest | |
needs: [integration_tests] | |
if: always() | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: 'recursive' | |
- name: Download kubectl and calicoctl for LKE clusters | |
run: | | |
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" | |
curl -LO "https://github.com/projectcalico/calico/releases/download/v3.25.0/calicoctl-linux-amd64" | |
chmod +x calicoctl-linux-amd64 kubectl | |
mv calicoctl-linux-amd64 /usr/local/bin/calicoctl | |
mv kubectl /usr/local/bin/kubectl | |
- name: Apply Calico Rules to LKE # Only Running against Matrix USER 4 which includes LKE test suite | |
run: | | |
cd e2e_scripts/cloud_security_scripts/lke_calico_rules/ && ./lke_calico_rules_e2e.sh | |
env: | |
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN_USER_4 }} | |
notify-slack: | |
runs-on: ubuntu-latest | |
needs: [integration_tests] | |
if: always() && github.repository == 'linode/terraform-provider-linode' # Run even if integration tests fail and only on main repository | |
steps: | |
- name: Notify Slack | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:" | |
} | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "section", | |
"fields": [ | |
{ | |
"type": "mrkdwn", | |
"text": "*Build Result:*\n${{ steps.integration_tests.outcome == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*Branch:*\n`${{ github.ref_name }}`" | |
} | |
] | |
}, | |
{ | |
"type": "section", | |
"fields": [ | |
{ | |
"type": "mrkdwn", | |
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>" | |
}, | |
{ | |
"type": "mrkdwn", | |
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>" | |
} | |
] | |
}, | |
{ | |
"type": "divider" | |
}, | |
{ | |
"type": "context", | |
"elements": [ | |
{ | |
"type": "mrkdwn", | |
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`" | |
} | |
] | |
} | |
] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |