Skip to content

Commit

Permalink
Merge branch 'master' into style-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed May 26, 2021
2 parents 2384197 + b6d4ca0 commit 9932675
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 31 deletions.
3 changes: 0 additions & 3 deletions .github/commit_comment_template.md

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# NOTE: For screenshots to work in untrusted PRs we need to do the screenshot comment in a trusted job like this one.
# See this post for details: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

name: Comment

on:
workflow_run:
workflows: ["Build"]
types:
- completed

jobs:
comment:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.conclusion == 'success' }} # && github.event.workflow_run.event == 'pull_request'
steps:
- uses: iterative/setup-cml@v1

# Doesn't work for fetching artifacts from separate workflows
#- name: Download screenshots
# uses: actions/download-artifact@v2
# with:
# name: screenshots
# path: screenshots

- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "screenshots"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/screenshots.zip', Buffer.from(download.data));
- run: unzip -d screenshots screenshots.zip

- name: Compose comment
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Here are screenshots of this commit:" >> comment.md
echo "" >> comment.md # just for the newline
for aw_server in screenshots/aw-*; do
for aw_version in screenshots/$aw_server/*; do
echo "<details><summary>Screenshots using $aw_server $aw_version (click to expand)</summary>" >> comment.md
echo '<p float="left">' >> comment.md
cml-publish screenshots/$aw_server/$aw_version/activity.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/$aw_server/$aw_version/timeline.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/$aw_server/$aw_version/settings.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/$aw_server/$aw_version/home.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/$aw_server/$aw_version/buckets.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/$aw_server/$aw_version/stopwatch.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
echo '</p>' >> comment.md
echo -n '</details>' >> comment.md
done
done
- name: Post screenshots in commit comment
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
head_sha: ${{ github.event.workflow_run.head_sha }}
run: |
cml-send-comment --commit-sha $head_sha --repo https://github.com/ActivityWatch/aw-webui comment.md
35 changes: 11 additions & 24 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Build

on:
Expand All @@ -21,7 +18,9 @@ jobs:
aw-server: ["aw-server", "aw-server-rust"]
aw-version: ["v0.10.0"]
include:
- aw-server: "aw-server-rust"
- node-version: '12.x'
python-version: '3.9'
aw-server: "aw-server-rust"
aw-version: "master"

steps:
Expand All @@ -36,7 +35,6 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: iterative/setup-cml@v1

# TODO: Refactor out getting ActivityWatch builds (both release and nightly) into an action
- name: Install and run ActivityWatch
Expand Down Expand Up @@ -102,26 +100,15 @@ jobs:
with:
name: build
path: dist/*
- name: Upload screenshots
uses: actions/upload-artifact@v2-preview
with:
name: screenshots
path: screenshots/*
- name: Post screenshots in commit comment
- name: Move screenshots to subdir
env:
repo_token: ${{ secrets.GITHUB_TOKEN }}
aw_server: ${{ matrix.aw-server }}
aw_version: ${{ matrix.aw-version }}
run: |
cat .github/commit_comment_template.md >> comment.md
echo "<details><summary>Screenshots using $aw_server $aw_version (click to expand)</summary>" >> comment.md
echo '<p float="left">' >> comment.md
cml-publish screenshots/activity.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/timeline.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/settings.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/home.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/buckets.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
cml-publish screenshots/stopwatch.png | sed -E 's/.+/<img width="45%" src="\0"\/>/' >> comment.md
echo '</p>' >> comment.md
echo -n '</details>' >> comment.md
cml-send-comment comment.md
mkdir -p screenshots/dist/$aw_server/$aw_version
mv screenshots/*.png screenshots/dist/$aw_server/$aw_version
- name: Upload screenshots
uses: actions/upload-artifact@v2-preview
with:
name: screenshots
path: screenshots/dist/*
29 changes: 25 additions & 4 deletions src/util/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ export const defaultCategories: Category[] = [
},
{
name: ['Work', 'Programming'],
rule: { type: 'regex', regex: 'GitHub|Stack Overflow|BitBucket|Gitlab|vim|Spyder|kate' },
rule: {
type: 'regex',
regex: 'GitHub|Stack Overflow|BitBucket|Gitlab|vim|Spyder|kate|Ghidra|Scite',
},
},
{
name: ['Work', 'Programming', 'ActivityWatch'],
rule: { type: 'regex', regex: 'ActivityWatch|aw-', ignore_case: true },
},
{ name: ['Work', 'Image'], rule: { type: 'regex', regex: 'Gimp|Inkscape' } },
{ name: ['Work', 'Video'], rule: { type: 'regex', regex: 'Kdenlive' } },
{ name: ['Work', 'Audio'], rule: { type: 'regex', regex: 'Audacity' } },
{ name: ['Work', '3D'], rule: { type: 'regex', regex: 'Blender' } },
{
name: ['Media', 'Games'],
rule: { type: 'regex', regex: 'Minecraft|RimWorld' },
Expand All @@ -46,12 +53,26 @@ export const defaultCategories: Category[] = [
{ name: ['Media', 'Video'], rule: { type: 'regex', regex: 'YouTube|Plex|VLC' } },
{
name: ['Media', 'Social Media'],
rule: { type: 'regex', regex: 'reddit|Facebook|Twitter|Instagram|devRant', ignore_case: true },
rule: {
type: 'regex',
regex: 'reddit|Facebook|Twitter|Instagram|devRant',
ignore_case: true,
},
},
{
name: ['Media', 'Music'],
rule: {
type: 'regex',
regex: 'Spotify|Deezer',
ignore_case: true,
},
},
{ name: ['Media', 'Music'], rule: { type: 'regex', regex: 'Spotify|Deezer', ignore_case: true } },
{
name: ['Comms', 'IM'],
rule: { type: 'regex', regex: 'Messenger|Telegram|Signal|WhatsApp|Rambox|Slack|Riot|Discord' },
rule: {
type: 'regex',
regex: 'Messenger|Telegram|Signal|WhatsApp|Rambox|Slack|Riot|Discord|Nheko',
},
},
{ name: ['Comms', 'Email'], rule: { type: 'regex', regex: 'Gmail|Thunderbird|mutt|alpine' } },
{ name: ['Uncategorized'], rule: { type: null }, data: { color: COLOR_UNCAT } },
Expand Down

0 comments on commit 9932675

Please sign in to comment.