-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
NAMESPACE="$1" | ||
RELEASE="$2" | ||
EVENT="$3" | ||
|
||
echo "Stats for $EVENT:" | ||
echo "Total launches: $(kubectl exec -n $NAMESPACE galaxy-$RELEASE-postgres-0 -- bash -c "psql -d galaxy -U galaxydbuser -c \"select count(j.id) from job j where j.tool_id like '%_%$EVENT%';\"" | sed '3q;d' | tr -d ' ')" | ||
echo "Total users: $(kubectl exec -n $NAMESPACE galaxy-$RELEASE-postgres-0 -- bash -c "psql -d galaxy -U galaxydbuser -c \"select count(DISTINCT j.user_id) from job j where j.tool_id like '%_%$EVENT%';\"" | sed '3q;d' | tr -d ' ')" | ||
|
||
printf "\nSummary:\n\nTOOL_ID NUM LAUNCHES NUM USERS\n" | ||
kubectl exec -n $NAMESPACE galaxy-$RELEASE-postgres-0 -- bash -c "psql -d galaxy -U galaxydbuser -c \"COPY(SELECT tool_id, COUNT(DISTINCT id) AS num_jobs, COUNT(DISTINCT user_id) AS num_users FROM job GROUP BY tool_id) TO STDOUT;\"" | grep "$EVENT" | sed 's/interactivetool_biocworkshop_//g' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Event stats workflow | ||
on: | ||
repository_dispatch: | ||
types: [eventstats-command] | ||
jobs: | ||
generatestats: | ||
name: Generate stats | ||
runs-on: ubuntu-latest | ||
env: | ||
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }} | ||
NAMESPACE: gxybioc | ||
RELEASE: gxy | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set defaults for all inputs | ||
id: defs | ||
run: | | ||
EVENTINPUT=${{ github.event.client_payload.slash_command.args.named.event || 'error' }} | ||
echo event=$EVENTINPUT >> $GITHUB_OUTPUT | ||
- name: save kubeconfig | ||
shell: bash | ||
run: mkdir -p ~/.kube && echo "${{ secrets.TEST_KUBECONFIG }}" > ~/.kube/config | ||
- name: Install Kubectl | ||
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" && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl && kubectl version | ||
|
||
- name: Get launch stats | ||
id: stats | ||
run: | | ||
TEXT=$(bash .github/scripts/event_stats.sh $NAMESPACE $RELEASE ${{steps.defs.outputs.event}}) | ||
echo text="$TEXT" >> $GITHUB_OUTPUT | ||
- name: Create comment | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
issue-number: ${{ github.event.client_payload.github.payload.issue.number }} | ||
body: | | ||
_AUTO-GENERATED RESPONSE_ | ||
'${{steps.stats.outputs.text}}' |
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