Skip to content

Commit

Permalink
chore: update CICD (#34)
Browse files Browse the repository at this point in the history
* chore: update CICD

* Unbuilt .qvf files into /diff

---------

Co-authored-by: qlik[bot] <username@users.noreply.github.com>
  • Loading branch information
withdave and qlik[bot] authored Jul 12, 2024
1 parent 52e2025 commit 2fef7f0
Show file tree
Hide file tree
Showing 33 changed files with 24,222 additions and 87 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/comment_checklist_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Comment on PR

on:
pull_request:
types: [opened, synchronize]
branches: [ "main" ]

workflow_dispatch:

jobs:
verify:
runs-on: ubuntu-latest
permissions: write-all
if: ${{ github.actor != 'dependabot[bot]' }} && ${{ github.actor != 'renovate[bot]' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Retrieve app name from release config
run: |
APPNAME=$(jq -r '.name' "release.json")
echo "APPNAME=$APPNAME" >> $GITHUB_ENV
- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
with:
mode: upsert
comment_tag: previewComment
message: |
# PR checklist
Checklist:
- [ ] Is the name of this app/solution still `${{ env.APPNAME }}`?
- [ ] Have you updated the version tag in each .qvf file, and followed semantic versioning (e.g. v1.1.1)?
- [ ] Is this PR named appropriately? For example:
- Feature release: `feat: add sheet usage event`
- Bug fix: `fix: replaced deprecated events`
- Documentation update: `docs: updated images in install guide`
- [ ] Have you reviewed the unbuilt diff generated by the workflow in /diff?
If you wish to merge and release:
- Have this PR approved by a code owner, then merge into main
- Go to releases, an action will generate a draft release with all files in /assets, and any external assets references in `release.json`
- Make any updates, then submit the release
Common issues:
- After merging, draft release doesn't update - this is usually because
the action failed due to an old draft release with the same name.
Delete the draft release, and re-run the action.
51 changes: 23 additions & 28 deletions .github/workflows/draft_release_on_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,23 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write

if: ${{ github.actor != 'dependabot[bot]' }} && ${{ github.actor != 'renovate[bot]' }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Retrieve version from VERSION
run: |
RELVER=$(cat VERSION | tr -d '[:space:]')
echo "RELVER=$RELVER" >> $GITHUB_ENV

- name: Retrieve app name from APPNAME
- name: Retrieve app name & assets from config
run: |
APPNAME=$(cat APPNAME)
APPNAME=$(jq -r '.name' "release.json")
echo "APPNAME=$APPNAME" >> $GITHUB_ENV
- name: Retrieve latest installer PDF from qlik-cloud-monitoring-apps repo
uses: robinraju/release-downloader@v1.10
with:
repository: "qlik-oss/qlik-cloud-monitoring-apps"
latest: true
fileName: "Qlik-Cloud-Monitoring-Applications-Installation-Guide.pdf"
URLS=$(jq -r '.externalAssets[].url' "release.json")
for URL in $URLS; do
FILENAME=$(basename "$URL")
# Perform desired operations with the URL
# Example: Download the file
curl -L -o "./assets/$FILENAME" "$URL"
done
- name: Draft a release
uses: softprops/action-gh-release@v2
Expand All @@ -40,25 +36,24 @@ jobs:
body: |
**!Important - review then remove this top section**
- [ ] Verify the .pdf and .qvf are correct
- [ ] Align the tag to the release version
- [ ] Verify release name matches tag (e.g. v1.2.1)
- [ ] Add any comments on breaking changes/ amends to the auto generated release notes
- [ ] Verify the resources from /assets are attached correctly to this release
- [ ] Set the tag to a semver matching the release (e.g. `v1.9.3`)
- [ ] Add any comments on breaking changes/ amends to the auto generated release notes below
- [ ] Delete this section
We are pleased to release version ${{ env.RELVER }} of the ${{ env.APPNAME }}.
Find attached the app (${{ env.APPNAME }}.qvf) and install guide (Qlik-Cloud-Monitoring-Applications-Installation-Guide.pdf).
We are pleased to release ${{ env.APPNAME }}. Assets are attached to this release for your convenience.
## What's Changed
The following changes have been made for this release:
- Change 1
- Change 2
- Change 1.
- Change 2.
- Change 3.
draft: true
tag_name: ${{ env.RELVER }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
./app/${{ env.APPNAME }}.qvf
./Qlik-Cloud-Monitoring-Applications-Installation-Guide.pdf
./assets/*
54 changes: 0 additions & 54 deletions .github/workflows/pr_verify.yml

This file was deleted.

121 changes: 121 additions & 0 deletions .github/workflows/unbuild_app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Unbuild app

on:
pull_request:
types: [opened, synchronize]
branches: [ "main" ]
paths:
- 'assets/**'

workflow_dispatch:

jobs:
unbuild:
runs-on: ubuntu-22.04
if: ${{ github.actor != 'dependabot[bot]' }} && ${{ github.actor != 'renovate[bot]' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Checkout repo
run: echo ${{ github.triggering_actor }}

- name: Download qlik-cli and unzip
run: |
wget https://github.com/qlik-oss/qlik-cli/releases/download/v2.25.0/qlik-Linux-x86_64.tar.gz -O qlik-cli.tar.gz
# Unzip archive
tar -xf qlik-cli.tar.gz
# Remove archive
rm qlik-cli.tar.gz
# Update permissions to execute
chmod +x qlik
- name: Retrieve qlik-cli version
run: ./qlik version

- name: Create context in qlik-cli
run: |
./qlik context create veritenant \
--server ${{ secrets.QLIK_CLOUD_MONITORING_TENANT }} \
--oauth-client-id ${{ secrets.QLIK_CLOUD_MONITORING_OAUTH_ID }} \
--oauth-client-secret ${{ secrets.QLIK_CLOUD_MONITORING_OAUTH_SECRET }} \
--server-type cloud
- name: Select context
run: ./qlik context use veritenant

- name: Delete any existing diff dir
run: rm -rf diff

- name: Config git
run: |
git config --global user.name "qlik[bot]"
git config --global user.email "username@users.noreply.github.com"
- name: Unbuild apps
run: |
shopt -s globstar nocaseglob
qUrl_list=()
for FILE in ./assets/*.qvf; do
FILENAME=$(basename "$FILE")
cp "$FILE" ./import.qvf # Handle for weird filenames and qlik-cli handling
APP_ID=$(./qlik raw post v1/apps/import --body-file "./import.qvf" | jq -r '.attributes.id')
echo "Imported appId $APP_ID"
./qlik app unbuild --app "$APP_ID" --dir "./diff/$FILENAME" --no-data

REPLACE_STRING="<appId>"

find "./diff/$FILENAME" -type f | while read -r UBFILEA; do
if [[ -f "$UBFILEA" ]]; then
sed -i "s/$APP_ID/$REPLACE_STRING/g" "$UBFILEA"
UBFILENAME=$(basename "$UBFILEA")
if [ "$(basename "$UBFILEA")" == "app-properties.json" ]; then
jq 'del(.qSavedInProductVersion)' "${UBFILEA}" > "${UBFILEA}.tmp" && mv "${UBFILEA}.tmp" "${UBFILEA}"
jq 'del(.qLastReloadTime)' "${UBFILEA}" > "${UBFILEA}.tmp" && mv "${UBFILEA}.tmp" "${UBFILEA}"
fi
fi
done

MEDIA_LIST=$(./qlik raw get "v1/apps/$APP_ID/media/list" --query "show=recursive")
IMAGE_LIST=$(echo "$MEDIA_LIST" | jq '[.[] | select(.type == "image") | {name: .name, link: .link}]')
IMAGE_COUNT=$(echo "$IMAGE_LIST" | jq 'length')
IMAGE_STORE_PATH="./diff/$FILENAME/images"
echo "Number of images found: $IMAGE_COUNT"


echo "$IMAGE_LIST" | jq -c '.[]' | while read -r IMAGE; do
if [ ! -d "$IMAGE_STORE_PATH" ]; then
mkdir -p "$IMAGE_STORE_PATH"
echo "Created directory: $IMAGE_STORE_PATH"
fi

IMG_NAME=$(echo "$IMAGE" | jq -r '.name')
IMG_LINK=$(echo "$IMAGE" | jq -r '.link')
IMG_PATH="${IMG_LINK#/api/}"
echo "Retrieving image: $IMG_NAME from: $IMG_PATH"
./qlik raw get "$IMG_PATH" --output-file "$IMAGE_STORE_PATH/$IMG_NAME"
done

./qlik app rm "$APP_ID"

done <<< "$FILE"


- name: Remove qlik-cli
run: rm qlik

- name: Commit /diff if changes
run: |
git add ./diff
GIT_STATUS=$(git status -uno -s)
if [ "$GIT_STATUS" ]; then
echo "git change summary: $GIT_STATUS"
git commit -m "Unbuilt .qvf files into /diff"
git push
else
echo "No changes found in /diff, skipping commit"
fi
1 change: 0 additions & 1 deletion APPNAME

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
> **Warning**
> This application is _community supported_. This means that you should not contact
> Qlik Support for help with this app. See below for additional information
> [!IMPORTANT]
> This project is _community supported_. This means that you should not contact
> Qlik Support for help with these apps. See below for additional information
> on how to raise issues on this repository to ask for help.
# Qlik Cloud Entitlement Analyzer
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

File renamed without changes.
10 changes: 10 additions & 0 deletions diff/Entitlement-Analyzer.qvf/app-properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"qTitle": "Entitlement Analyzer v2.3.0",
"qThumbnail": {
"qUrl": "/api/v1/apps/<appId>/media/files/UserAnalyzer.png"
},
"description": "The Entitlement Analyzer provides a comprehensive dashboard to analyze entitlement consumption and assignments across a Qlik Sense tenant(s).\n\n{v2.3.0}",
"qUsage": "ANALYTICS",
"published": false,
"hassectionaccess": false
}
7 changes: 7 additions & 0 deletions diff/Entitlement-Analyzer.qvf/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
script: script.qvs
connections: connections.yml
dimensions: dimensions.json
measures: measures.json
objects: objects/*.json
variables: variables.json
app-properties: app-properties.json
16 changes: 16 additions & 0 deletions diff/Entitlement-Analyzer.qvf/connections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
connections:
MyDataFiles:
type: qix-datafiles.exe
connectionstring: CUSTOM CONNECT TO "provider=qix-datafiles.exe;path=mydatafiles;"
username:
password:
DataFiles:
type: qix-datafiles.exe
connectionstring: CUSTOM CONNECT TO "provider=qix-datafiles.exe;path=datafiles;"
username:
password:
DataPrepAppCache:
type: qix-datafiles.exe
connectionstring: CUSTOM CONNECT TO "provider=qix-datafiles.exe;path=dataprepappcache;"
username:
password:
Loading

0 comments on commit 2fef7f0

Please sign in to comment.