Skip to content

Actions workflow to sync icons to the bucket #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ffad40e
rename
max-ostapenko Mar 2, 2025
d463961
icon upload action
max-ostapenko Mar 3, 2025
7aeb37a
lint
max-ostapenko Mar 3, 2025
def0a0a
format
max-ostapenko Mar 3, 2025
8ff11b2
Merge branch 'main' into fix-icon-extension
max-ostapenko Mar 18, 2025
2654e62
use rsync for upload
max-ostapenko Apr 2, 2025
2173e1c
cache header
max-ostapenko Apr 2, 2025
b8863ca
cleanup
max-ostapenko Apr 2, 2025
e8c8ae3
keep local convert
max-ostapenko Apr 2, 2025
4bd8583
test branch
max-ostapenko Apr 2, 2025
583fdea
Merge branch 'main' into fix-icon-extension
max-ostapenko Apr 2, 2025
a60de20
fix path
max-ostapenko Apr 3, 2025
35d24e9
test with extended depth
max-ostapenko Apr 3, 2025
0d4e2aa
to trigger the action
max-ostapenko Apr 3, 2025
80117b4
fix SA key
max-ostapenko Apr 3, 2025
0ab2b75
try sa auth fix
max-ostapenko Apr 3, 2025
2f974f1
one more try
max-ostapenko Apr 3, 2025
a6d861b
standard action
max-ostapenko Apr 3, 2025
07b9688
fixed path
max-ostapenko Apr 3, 2025
14e3281
fixed png copy
max-ostapenko Apr 3, 2025
ed53ed2
fix project
max-ostapenko Apr 3, 2025
ce77f5f
check new permissioms
max-ostapenko Apr 3, 2025
cc23a7b
gcloud config
max-ostapenko Apr 3, 2025
c0e8dab
new secret
max-ostapenko Apr 3, 2025
bf378ee
without gzip
max-ostapenko Apr 3, 2025
86c4cbe
extended history
max-ostapenko Apr 3, 2025
d1e6dc7
regex fix
max-ostapenko Apr 3, 2025
a83dd9d
test increment
max-ostapenko Apr 3, 2025
9d94832
cleanup
max-ostapenko Apr 3, 2025
b6ac801
PR head
max-ostapenko Apr 3, 2025
489fc8c
reset changes
max-ostapenko Apr 3, 2025
45b63e1
force sync
max-ostapenko Apr 3, 2025
cd7df4e
prod path
max-ostapenko Apr 3, 2025
011a4c6
duplicate lint task
max-ostapenko Apr 4, 2025
5448ad6
unused
max-ostapenko Apr 4, 2025
961fbb7
bring back gitkeep
max-ostapenko Apr 4, 2025
0b3e6c9
lint deduplicated
max-ostapenko Apr 4, 2025
9e94eec
no stalebots
max-ostapenko Apr 4, 2025
e91a537
comment
max-ostapenko Apr 4, 2025
e386141
split scripts
max-ostapenko Apr 4, 2025
2ebecef
test trigger
max-ostapenko Apr 4, 2025
defe23a
node vs yarn
max-ostapenko Apr 4, 2025
5961532
back to yarn
max-ostapenko Apr 4, 2025
ef68932
cleanup
max-ostapenko Apr 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Linting
name: Lint & Validate

on:
pull_request_target:
branches:
- main
workflow_dispatch:
paths-ignore:
- "src/technologies/*.json"
- "src/categories.json"
- "src/groups.json"
- "src/images/icons/**"

jobs:
lint:
name: Lint
name: Lint & Validate
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -20,9 +24,7 @@ jobs:
- name: Install dependencies
run: yarn install

- name: Validate
run: yarn run validate

- name: Run WebPageTest with unit tests
id: unit-test
run: yarn run lint
- name: Lint and Validate
run: |
yarn run lint
yarn run validate
23 changes: 0 additions & 23 deletions .github/workflows/stale.yml

This file was deleted.

7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- "src/categories.json"
- "src/groups.json"
- "tests/*.js"
- ".github/workflows/test.yml"
workflow_dispatch:

jobs:
Expand All @@ -25,8 +26,10 @@ jobs:
- name: Install dependencies
run: yarn install

- name: Validate
run: yarn run validate
- name: Lint & Validate
run: |
yarn run lint
yarn run validate

- name: Run WebPageTest with unit tests
id: unit-test
Expand Down
74 changes: 60 additions & 14 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,91 @@
name: Tests
name: Upload technologies to BQ and Cloud Storage

on:
push:
branches:
- main
paths:
- ".github/workflows/upload.yml"
- "src/technologies/*.json"
- "src/categories.json"
- "src/groups.json"
- "src/images/icons/**"
workflow_dispatch:
inputs:
force_update:
description: 'Force update regardless of changes'
required: false
default: 'false'

jobs:
test:
name: Test and upload to GCP
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Install dependencies
run: yarn install

- name: Validate
run: yarn run validate

- name: Run WebPageTest with unit tests
id: unit-test
env:
WPT_SERVER: "webpagetest.httparchive.org"
WPT_API_KEY: ${{ secrets.HA_API_KEY }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: yarn run test
- name: Get changed technology files
run: |
git log -1 HEAD^
git log -1 HEAD

git fetch origin main --depth=1
TECH_FILES_CHANGED=$(git diff --name-only HEAD^ HEAD -- 'src/technologies/*.json' 'src/categories.json' 'src/groups.json' | wc -l)
echo $TECH_FILES_CHANGED
echo "TECH_FILES_CHANGED=${TECH_FILES_CHANGED}" >> $GITHUB_ENV

- name: Upload to GCP
id: upload
- name: Upload technology rules to BigQuery
if: env.TECH_FILES_CHANGED != '' || inputs.force_update == 'true'
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
run: yarn run tech_upload

- name: Get changed icons
run: |
git fetch origin main --depth=1

if [[ "${{ inputs.force_update }}" == "true" ]]; then
CHANGED_ICONS=$(find src/images/icons -name "*.svg" -o -name "*.png" | xargs)
else
CHANGED_ICONS=$(git diff --name-only HEAD^ HEAD -- 'src/images/icons/*.svg' 'src/images/icons/*.png' | xargs)
fi

echo $CHANGED_ICONS
echo "CHANGED_ICONS=${CHANGED_ICONS}" >> $GITHUB_ENV

# PNG are generally smaller, and we have some SVG that are 1Mb, so conversion to PNG is necessary.
- name: Install Image Conversion Package
if: env.CHANGED_ICONS != ''
run: sudo apt-get install -y librsvg2-bin

- name: Convert changed SVGs to PNGs
if: env.CHANGED_ICONS != ''
run: |
for file in $CHANGED_ICONS; do
if [[ "$file" == *.svg ]]; then
rsvg-convert "$file" -o "${file%.svg}.png" -w 16 -h 16
fi
done
Comment on lines +71 to +78
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we use SVGs if in that format already? Maybe add a comment to explain?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PNG are generally smaller, and we have some SVG that are 1Mb.
Added comment to YML.


- uses: 'google-github-actions/auth@v2'
if: env.CHANGED_ICONS != '' || inputs.force_update == 'true'
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- uses: 'google-github-actions/setup-gcloud@v2'
if: env.CHANGED_ICONS != '' || inputs.force_update == 'true'

- name: Sync new PNGs to Cloud Storage
if: env.CHANGED_ICONS != '' || inputs.force_update == 'true'
run: |
echo $GCP_SA_KEY > /tmp/gcp_key.json
yarn run upload
gcloud storage rsync src/images/icons/ gs://httparchive/static/icons/ --exclude=".*.svg$" --cache-control="public, max-age=31536000, immutable"
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"scripts": {
"lint": "eslint src/**/*.{js,json} tests/**/*.js scripts/**/*.js && jsonlint -jsV ./schema.json --trim-trailing-commas --enforce-double-quotes ./src/technologies/ && jsonlint -js --trim-trailing-commas --enforce-double-quotes ./src/categories.json",
"lint:fix": "eslint --fix src/**/*.{js,json} tests/**/*.js scripts/**/*.js && jsonlint -isV ./schema.json --trim-trailing-commas --enforce-double-quotes ./src/technologies/ && jsonlint -is --trim-trailing-commas --enforce-double-quotes ./src/categories.json",
"validate": "yarn run lint && node ./scripts/validate.js",
"validate": "node ./scripts/validate.js",
"test": "jest",
"upload": "node ./scripts/bigquery_upload.js",
"convert": "node --no-warnings ./scripts/convert.js",
"build": "yarn run validate && yarn run convert && node ./scripts/build.js"
"tech_upload": "node ./scripts/tech_upload.js",
"convert": "node ./scripts/convert.js",
"build": "yarn run lint && yarn run validate && yarn run convert && node ./scripts/build.js"
},
"jest": {
"reporters": [
Expand Down
2 changes: 0 additions & 2 deletions scripts/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,10 @@ function dateDiff(file) {
})()

/**

cd ; cp *.svg converted ; cd converted ; convert-svg-to-png *.svg --width 32 --height 32 ; rm *.svg
(async() => {
const inputFilePath = '/path/to/my-image.svg';
const outputFilePath = await convertFile(inputFilePath);

console.log(outputFilePath);
//=> "/path/to/my-image.png"
})();
Expand Down
23 changes: 11 additions & 12 deletions scripts/bigquery_upload.js → scripts/tech_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const path = require('path')
const { BigQuery } = require('@google-cloud/bigquery')

const bigquery = new BigQuery({
keyFilename: '/tmp/gcp_key.json',
credentials: JSON.parse(process.env.GCP_SA_KEY),
})

const schemas = {
Expand Down Expand Up @@ -200,17 +200,16 @@ const main = async () => {
app[field] = getRuleObject(technologies[key][field])
}
)
;[
'website',
'description',
'icon',
'cpe',
'saas',
'oss',
'pricing',
].forEach((field) => {
app[field] = technologies[key][field]
})
;['website', 'description', 'cpe', 'saas', 'oss', 'pricing'].forEach(
(field) => {
app[field] = technologies[key][field]
}
)

// Handle icon field separately to ensure .png extension
app.icon = technologies[key].icon
? `${technologies[key].icon.replace(/\.[^/.]+$/, '')}.png`
: technologies[key].icon

return app
})
Expand Down
58 changes: 0 additions & 58 deletions scripts/upload_icons.js

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,5 @@ fs.readdirSync(iconPath).forEach((file) => {
}
}
})

console.log('Validation completed successfully.')
2 changes: 1 addition & 1 deletion src/images/icons/1C-Bitrix.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 14 additions & 14 deletions src/technologies/e.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,6 @@
],
"website": "https://erpnext.com"
},
"Essential Blocks": {
"cats": [
87
],
"description": "Essential Blocks is a Gutenberg Blocks page builder plugin that adds extra functionality to the WordPress Block Editor.",
"icon": "essential-blocks.png",
"requires": "WordPress",
"dom": [
"link[href*='/wp-content/uploads/eb-style/']",
"link#essential-blocks-frontend-style-css"
],
"html": "<div[^>]+class=[\"']wp-block-essential-blocks-*",
"website": "https://essential-blocks.com"
},
"ESW": {
"cats": [
106
Expand Down Expand Up @@ -1492,6 +1478,20 @@
"scriptSrc": "/wp-content/uploads/essential-addons-elementor/",
"website": "https://essential-addons.com/elementor/"
},
"Essential Blocks": {
"cats": [
87
],
"description": "Essential Blocks is a Gutenberg Blocks page builder plugin that adds extra functionality to the WordPress Block Editor.",
"dom": [
"link[href*='/wp-content/uploads/eb-style/']",
"link#essential-blocks-frontend-style-css"
],
"html": "<div[^>]+class=[\"']wp-block-essential-blocks-*",
"icon": "essential-blocks.png",
"requires": "WordPress",
"website": "https://essential-blocks.com"
},
"Essential JS 2": {
"cats": [
12,
Expand Down
8 changes: 4 additions & 4 deletions src/technologies/g.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,13 +448,13 @@
87
],
"description": "Premium block library & block editor enhancements from StudioPress.",
"icon": "genesis-blocks.png",
"requires": "WordPress",
"dom": [
"link[href*='/wp-content/plugins/atomic-blocks']",
"link[href*='/wp-content/plugins/atomic-blocks']",
"link[href*='/wp-content/plugins/genesis-blocks']"
],
"html": "<div[^>]+class=[\"']wp-block-atomic-blocks-*",
"icon": "genesis-blocks.png",
"requires": "WordPress",
"scriptSrc": "/wp-content/themes/genesis-blocks/lib/js/",
"website": "https://www.studiopress.com/genesis-blocks/"
},
Expand All @@ -463,12 +463,12 @@
80
],
"description": "Genesis theme is a WordPress theme that has been developed using the Genesis Framework from Studiopress.",
"icon": "Genesis theme.svg",
"dom": [
"body[class*='theme-genesis']",
"body[class*='genesis-breadcrumbs-hidden']",
"body[class*='genesis-title-hidden']"
],
"icon": "Genesis theme.svg",
"requires": "WordPress",
"scriptSrc": "/wp-content/themes/genesis/lib/js/",
"website": "https://www.studiopress.com/themes/genesis"
Expand Down
Loading