[MTM-59397] As a plugin developer I want to have a workflow that will collect shell versions and run cypress tests against them #58
Workflow file for this run
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: Collect shell versions | |
on: | |
pull_request: # TODO: change workflow trigger | |
permissions: | |
contents: read | |
env: | |
ACTIONS_STEP_DEBUG: true | |
jobs: | |
collect-shell-versions: | |
timeout-minutes: 30 | |
runs-on: ubuntu-22.04 | |
outputs: | |
non_deprecated_shell_versions: ${{ steps.collect-shell-versions.outputs.non_deprecated_shell_versions }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Get @c8y/ngx-components, non-deprecated dist versions | |
id: collect-shell-versions | |
run: npm run collect-shell-versions | |
- name: Extract versions | |
id: extract-versions | |
run: | | |
echo "::set-output name=non_deprecated_shell_versions::${{steps.collect-shell-versions.outputs.non_deprecated_shell_versions}}" | |
build-plugins: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build | |
if-no-files-found: error | |
retention-days: 5 | |
path: | | |
dist/sag-pkg-community-plugins/** | |
run-tests-against-shell: | |
needs: [collect-shell-versions, build-plugins] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
version_data: ${{ fromJson(needs.collect-shell-versions.outputs.non_deprecated_shell_versions) }} | |
env: | |
JSON: ${{ toJson(matrix.version_data) }} | |
VERSION: ${{ matrix.version_data.version }} | |
MAJOR: ${{ matrix.version_data.major }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
cache: 'npm' | |
- name: Download build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build | |
path: dist/apps/sag-pkg-community-plugins/ | |
- name: Get shell app of particular version | |
run: | | |
set -e # Exit the script if any command fails | |
# Get shell version from current env | |
shell_version="${{ env.VERSION }}" | |
echo "Shell version is: $shell_version" | |
# Construct the file URL | |
file_url="http://resources.cumulocity.com/webapps/ui-releases/apps-${shell_version}.tgz" | |
echo "Shell file url is: $file_url" | |
# Download the file | |
echo "Downloading file..." | |
curl -O $file_url | |
if [ ! -f "apps-${shell_version}.tgz" ]; then | |
echo "Downloaded file not found!" | |
exit 1 | |
fi | |
echo "File downloaded successfully." | |
# Extract the downloaded tar.gz file | |
echo "Extracting apps from downloaded file..." | |
tar -xzf "apps-${shell_version}.tgz" | |
if [ $? -ne 0 ]; then | |
echo "Extraction failed!" | |
exit 1 | |
fi | |
echo "Apps extracted successfully." | |
# Unzip Cockpit to dist/apps | |
cockpit_file="cockpit-${shell_version}.zip" | |
destination_folder="dist/apps/cockpit" | |
mkdir -p "$destination_folder" | |
unzip -qq "$cockpit_file" -d "$destination_folder" | |
if [ $? -ne 0 ]; then | |
echo "Extracting cockpit file failed!" | |
exit 1 | |
fi | |
echo "Cockpit extracted successfully." | |
# Echo the elements of dist/apps | |
echo "Contents of dist/apps:" | |
ls dist/apps | |
- name: Cypress run | |
uses: cypress-io/github-action@v5 | |
with: | |
start: npm run cypress:ctrl | |
install: false | |
wait-on: 'http://localhost:4200/apps/cockpit/index.html?remotes=%7B"sag-pkg-community-plugins"%3A%5B"ExampleWidgetPluginModule"%2C"DatapointsGraphWidgetModule"%5D%7D#' | |
browser: chrome | |
record: false | |
config-file: cypress.config.ts | |
env: C8Y_CTRL_MODE=mocking,grepTags=@${{ env.MAJOR }} | |
- name: Upload cypress screenshots | |
uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
retention-days: 5 | |
name: cypress-screenshots | |
path: cypress/screenshots | |
- name: Upload cypress videos | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
retention-days: 5 | |
name: cypress-videos | |
path: cypress/videos |