Skip to content

Commit

Permalink
AG-26623 CI workflows for CSS Tokenizer
Browse files Browse the repository at this point in the history
Merge in ADGUARD-FILTERS/tsurlfilter from feature/AG-26623-4 to master

Squashed commit of the following:

commit d06cc54
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 30 16:13:50 2023 +0100

    Delete files

commit a7202d7
Merge: b3ebae5 4b1a799
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 30 16:11:37 2023 +0100

    Merge branch 'master' into feature/AG-26623-4

commit b3ebae5
Merge: 6275efb 993e1cc
Author: scripthunter7 <d.tota@adguard.com>
Date:   Fri Oct 20 17:29:36 2023 +0200

    Merge branch 'feature/AG-26623-1' into feature/AG-26623-4

commit 6275efb
Author: scripthunter7 <d.tota@adguard.com>
Date:   Fri Oct 20 17:28:19 2023 +0200

    Add increment script

commit 993e1cc
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Fri Oct 20 12:28:39 2023 +0300

    AG-26623 CSS Tokenizer benchmark

    Merge in ADGUARD-FILTERS/tsurlfilter from feature/AG-26623-7 to feature/AG-26623-1

    Squashed commit of the following:

    commit fb16b12
    Merge: e298be1 b520120
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Fri Oct 20 10:58:26 2023 +0200

        Merge branch 'feature/AG-26623-1' into feature/AG-26623-7

    commit e298be1
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Fri Oct 20 10:55:08 2023 +0200

        Benchmark README

    commit d2adfee
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Fri Oct 20 10:54:49 2023 +0200

        Add build to benchmark script

    commit e20784c
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Thu Oct 19 14:52:52 2023 +0200

        Benchmark Extended CSS fork

    commit d7f4ca6
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Thu Oct 19 14:37:40 2023 +0200

        Add url

    commit 4f7e9c1
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Thu Oct 19 14:30:27 2023 +0200

        Fix types

    commit d059f29
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Thu Oct 19 14:19:52 2023 +0200

        CSS Tokenizer benchmark

commit b520120
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Fri Oct 20 11:47:33 2023 +0300

    AG-26623 Optimize CSS tokenizer

    Merge in ADGUARD-FILTERS/tsurlfilter from feature/AG-26623-8 to feature/AG-26623-1

    Squashed commit of the following:

    commit 35a2840
    Merge: ea95983 ca47032
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Fri Oct 20 10:36:08 2023 +0200

        Merge branch 'feature/AG-26623-1' into feature/AG-26623-8

    commit ea95983
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Thu Oct 19 14:58:20 2023 +0200

        Optimize CSS tokenizer

commit ca47032
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Wed Oct 18 12:47:16 2023 +0300

    AG-26623 Improve Extended CSS tokenization

    Merge in ADGUARD-FILTERS/tsurlfilter from feature/AG-26623-6 to feature/AG-26623-1

    Squashed commit of the following:

    commit 7d9c9ed
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Wed Oct 18 10:13:29 2023 +0200

        Fix nits

    commit 9d5dd3e
    Merge: c18515d 02fb7f7
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 18:02:48 2023 +0200

        Merge branch 'feature/AG-26623-1' into feature/AG-26623-6

    commit c18515d
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 17:50:29 2023 +0200

        More robust Extended CSS tests

    commit 146b808
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 17:49:07 2023 +0200

        Improve Extended CSS tokenization

commit 02fb7f7
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Tue Oct 17 19:01:12 2023 +0300

    AG-26623 CSS Tokenizer README badges

    Merge in ADGUARD-FILTERS/tsurlfilter from feature/AG-26623-5 to feature/AG-26623-1

    Squashed commit of the following:

    commit dd1d0be
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 16:08:14 2023 +0200

        README badges

commit bc5d53f
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Tue Oct 17 16:25:39 2023 +0300

    AG-26623 CSS tokenizer tests

    Merge in ADGUARD-FILTERS/tsurlfilter from feature/AG-26623-2 to feature/AG-26623-1

    Squashed commit of the following:

    commit 3371271
    Merge: 1d5b654 d46a3db
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 14:59:45 2023 +0200

        Merge branch 'feature/AG-26623-1' into feature/AG-26623-2

    commit 1d5b654
    Merge: ef19b87 f531df1
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 14:45:47 2023 +0200

        Merge branch 'feature/AG-26623-1' into feature/AG-26623-2

    commit ef19b87
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 13:08:56 2023 +0200

        Fix test messages

    commit 29c332b
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 11:26:34 2023 +0200

        Test all possible errors

    commit 5722aae
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Tue Oct 17 11:26:14 2023 +0200

        Reuse main test logic

    commit 6a775df
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Fri Oct 13 17:22:39 2023 +0200

        Tests for CSS tokenizer

    commit 16645a8
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Fri Oct 13 17:19:47 2023 +0200

        Update Jest config

commit d46a3db
Author: Dávid Tóta <d.tota@adguard.com>
Date:   Tue Oct 17 12:02:47 2023 +0300

    AG-26623 CSS tokenizer README, markdownlint

    Merge in ADGUARD-FILTERS/tsurlfilter from feature/AG-26623-3 to feature/AG-26623-1

    Squashed commit of the following:

    commit 8455caf
    Merge: dc7c5f5 f531df1
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Mon Oct 16 18:35:59 2023 +0200

        Merge branch 'feature/AG-26623-1' into feature/AG-26623-3

    commit dc7c5f5
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Mon Oct 16 14:31:36 2023 +0200

        Improve lint command

    commit 374302c
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Mon Oct 16 14:21:21 2023 +0200

        Add README

    commit 6a02df3
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Mon Oct 16 13:52:27 2023 +0200

        Configure markdownlint

    commit fd90c41
    Author: scripthunter7 <d.tota@adguard.com>
    Date:   Mon Oct 16 13:52:13 2023 +0200

        Install markdownlint

commit f92b92b
Merge: ef2e716 f531df1
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 16 17:19:54 2023 +0200

    Merge branch 'feature/AG-26623-1' into feature/AG-26623-4

commit f531df1
Merge: ed8de56 1f1fe7e
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 16 15:43:08 2023 +0200

    Merge remote-tracking branch 'origin/master' into feature/AG-26623-1

commit ef2e716
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 16 14:53:00 2023 +0200

    Bump docker image versions for css tokenizer

commit 5623797
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 16 14:42:44 2023 +0200

    Bamboo specs for CSS Tokenizer lib

commit 184c4f8
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 16 14:41:03 2023 +0200

    Improve GH test workflow

commit c86f638
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Oct 16 14:40:27 2023 +0200

    Build txt with version

commit ed8de56
Author: scripthunter7 <d.tota@adguard.com>
Date:   Fri Oct 13 16:09:53 2023 +0200

    Update token data helper

commit f3aeafc
Author: scripthunter7 <d.tota@adguard.com>
Date:   Fri Oct 13 16:09:38 2023 +0200

    Change context constructor

commit 40e0c30
Author: scripthunter7 <d.tota@adguard.com>
Date:   Fri Oct 13 16:09:24 2023 +0200

    Fix string consumer

commit 3eaab88
Author: scripthunter7 <d.tota@adguard.com>
Date:   Fri Oct 13 16:09:06 2023 +0200

    Update main tokenizer

... and 12 more commits
  • Loading branch information
scripthunter7 committed Oct 30, 2023
1 parent 4b1a799 commit f89b784
Show file tree
Hide file tree
Showing 10 changed files with 364 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ jobs:
npx lerna@6 run --scope @adguard/agtree test
npx lerna@6 run --scope @adguard/agtree build
# css-tokenizer
npx lerna@6 run --scope @adguard/css-tokenizer check-types
npx lerna@6 run --scope @adguard/css-tokenizer lint
npx lerna@6 run --scope @adguard/css-tokenizer test
npx lerna@6 run --scope @adguard/css-tokenizer build
# tsurlfilter
npx lerna@6 run --scope @adguard/tsurlfilter lint
npx lerna@6 run --scope @adguard/tsurlfilter build
Expand Down
15 changes: 15 additions & 0 deletions bamboo-specs/bamboo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@

---
!include 'agtree-permissions.yaml'

---
!include 'css-tokenizer-test.yaml'

---
!include 'css-tokenizer-increment.yaml'

---
!include 'css-tokenizer-build.yaml'

---
!include 'css-tokenizer-deploy.yaml'

---
!include 'css-tokenizer-permissions.yaml'
93 changes: 93 additions & 0 deletions bamboo-specs/css-tokenizer-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
version: 2
plan:
project-key: AJL
key: CSSTOKENIZERBUILD
name: CSS Tokenizer - build
variables:
dockerContainer: adguard/node-ssh:18.13--1

stages:
- Build:
manual: 'false'
final: 'false'
jobs:
- Build

Build:
key: BUILD
other:
clean-working-dir: true
docker:
image: "${bamboo.dockerContainer}"
volumes:
"${system.YARN_DIR}": "${bamboo.cacheYarn}"
tasks:
- checkout:
force-clean-build: 'true'
- script:
interpreter: SHELL
scripts:
- |-
set -e
set -x
# Fix mixed logs
exec 2>&1
ls -alt
# Bootstrap the package with Lerna
npx lerna@6 bootstrap --scope @adguard/css-tokenizer --include-dependencies
# Build CSS Tokenizer with Rollup
npx lerna@6 run --scope @adguard/css-tokenizer build
# Pack the CSS Tokenizer package into a tarball
cd packages/css-tokenizer/
yarn pack --filename css-tokenizer.tgz
cd ../../
# Cleanup parent
rm -rf node_modules
# Cleanup child packages
npx lerna@6 clean -y
- inject-variables:
file: ./packages/css-tokenizer/dist/build.txt
scope: RESULT
namespace: inject
- any-task:
plugin-key: com.atlassian.bamboo.plugins.vcs:task.vcs.tagging
configuration:
selectedRepository: defaultRepository
tagName: css-tokenizer-v${bamboo.inject.version}
# Store the CSS Tokenizer package tarball as an artifact
artifacts:
- name: css-tokenizer.tgz
location: packages/css-tokenizer/
pattern: css-tokenizer.tgz
shared: true
required: true
requirements:
- adg-docker: 'true'

triggers: []

branches:
create: manually
delete: never
link-to-jira: 'true'

notifications:
- events:
- plan-status-changed
recipients:
- webhook:
name: Build webhook
url: http://prod.jirahub.service.eu.consul/v1/webhook/bamboo

labels: []

other:
concurrent-build-plugin: system-default
47 changes: 47 additions & 0 deletions bamboo-specs/css-tokenizer-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
version: 2
deployment:
name: CSS Tokenizer - deploy
source-plan: AJL-CSSTOKENIZERBUILD
release-naming: ${bamboo.inject.version}
environments:
- npmjs

npmjs:
docker:
image: adguard/node-ssh:18.13--1
volumes:
${system.YARN_DIR}: "${bamboo.cacheYarn}"
triggers: [ ]
tasks:
- checkout:
force-clean-build: 'true'
# Download previously built tarball from Bamboo artifacts
- artifact-download:
artifacts:
- name: css-tokenizer.tgz
- script:
interpreter: SHELL
scripts:
- |-
set -e
set -x
# Fix mixed logs
exec 2>&1
ls -alt
# Publish tarball to NPM package registry
export NPM_TOKEN=${bamboo.npmSecretToken}
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
npm publish css-tokenizer.tgz --access public
requirements:
- adg-docker: 'true'
notifications:
- events:
- deployment-started-and-finished
recipients:
- webhook:
name: Deploy webhook
url: http://prod.jirahub.service.eu.consul/v1/webhook/bamboo
65 changes: 65 additions & 0 deletions bamboo-specs/css-tokenizer-increment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
version: 2
plan:
project-key: AJL
key: CSSTOKENIZERINCR
name: CSS Tokenizer - increment
variables:
dockerContainer: adguard/node-ssh:18.13--1

stages:
- Increment:
manual: 'true'
final: 'false'
jobs:
- Increment

Increment:
key: INCRCSSTOKENIZER
docker:
image: "${bamboo.dockerContainer}"
volumes:
"${system.YARN_DIR}": "${bamboo.cacheYarn}"
tasks:
- checkout:
force-clean-build: 'true'
- script:
interpreter: SHELL
scripts:
- |-
branch="${bamboo.planRepository.branchName}"
# Throw error if current branch is not "master",
# because we do not deploy changes from other branches
if [ $branch != "master" ]
then
echo "increment is not supported on branch ${branch}"
exit 1;
fi
set -e
set -x
# Fix mixed logs
exec 2>&1
ls -alt
npx lerna@6 run --scope @adguard/css-tokenizer increment
- any-task:
plugin-key: com.atlassian.bamboo.plugins.vcs:task.vcs.commit
configuration:
commitMessage: 'skipci: Automatic increment build number'
selectedRepository: defaultRepository
requirements:
- adg-docker: 'true'

branches:
create: manually
delete: never
link-to-jira: 'true'

labels: [ ]

other:
concurrent-build-plugin: system-default
16 changes: 16 additions & 0 deletions bamboo-specs/css-tokenizer-permissions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
version: 2
deployment:
name: CSS Tokenizer - deploy
deployment-permissions:
- groups:
- extensions-developers
permissions:
- view
environment-permissions:
- npmjs:
- groups:
- extensions-developers
permissions:
- view
- deploy
78 changes: 78 additions & 0 deletions bamboo-specs/css-tokenizer-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
version: 2
plan:
project-key: AJL
key: CSSTOKENIZERTEST
name: CSS Tokenizer - tests
variables:
dockerContainer: adguard/node-ssh:18.13--1

stages:
- Test:
manual: 'false'
final: 'false'
jobs:
- Test

Test:
key: TEST
docker:
image: "${bamboo.dockerContainer}"
volumes:
"${system.YARN_DIR}": "${bamboo.cacheYarn}"
tasks:
- checkout:
force-clean-build: 'true'
- script:
interpreter: SHELL
scripts:
- |-
set -e
set -x
# Fix mixed logs
exec 2>&1
ls -alt
# Bootstrap the package
npx lerna@6 bootstrap --scope @adguard/css-tokenizer --include-dependencies
# Check TypeScript types with TSC
npx lerna@6 run --scope @adguard/css-tokenizer check-types
# ESLint & Markdownlint
npx lerna@6 run --scope @adguard/css-tokenizer lint
# Run tests with Jest
npx lerna@6 run --scope @adguard/css-tokenizer test
# cleanup parent
rm -rf node_modules
# cleanup child packages
npx lerna@6 clean -y
final-tasks:
- clean
requirements:
- adg-docker: 'true'

branches:
create: for-pull-request
delete:
after-deleted-days: '1'
after-inactive-days: '5'
link-to-jira: 'true'

notifications:
- events:
- plan-status-changed
recipients:
- webhook:
name: Build webhook
url: http://prod.jirahub.service.eu.consul/v1/webhook/bamboo

labels: [ ]

other:
concurrent-build-plugin: system-default
4 changes: 3 additions & 1 deletion packages/css-tokenizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
"dist"
],
"scripts": {
"build": "yarn clean && yarn build-types && yarn rollup --config rollup.config.ts --configPlugin @rollup/plugin-json --configPlugin @rollup/plugin-typescript && yarn clean-types",
"build": "yarn clean && yarn build-types && yarn build-txt && yarn rollup --config rollup.config.ts --configPlugin @rollup/plugin-json --configPlugin @rollup/plugin-typescript && yarn clean-types",
"build-txt": "yarn ts-node scripts/build-txt.ts",
"build-types": "tsc --declaration --emitDeclarationOnly --outdir dist/types",
"benchmark": "yarn build && node -r esbuild-register benchmark/index.ts",
"check-types": "tsc --noEmit",
"clean": "rimraf dist",
"clean-types": "rimraf dist/types",
"coverage": "jest --coverage",
"increment": "yarn version --patch --no-git-tag-version",
"lint": "yarn lint:ts && yarn lint:md",
"lint:md": "markdownlint .",
"lint:ts": "eslint . --cache --ext .ts",
Expand Down
40 changes: 40 additions & 0 deletions packages/css-tokenizer/scripts/build-txt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @file Output the version number to a build.txt file
*/
import fs from 'fs';
import path from 'path';

const UPPER_LEVEL = '../';

const DIST_FOLDER_NAME = 'dist';
const OUTPUT_FILE_NAME = 'build.txt';
const PKG_FILE_NAME = 'package.json';

// Computed constants
const distFolderLocation = path.join(__dirname, UPPER_LEVEL, DIST_FOLDER_NAME);
const pkgFileLocation = path.join(__dirname, UPPER_LEVEL, PKG_FILE_NAME);

// Read package.json
const pkg = JSON.parse(fs.readFileSync(pkgFileLocation, 'utf-8'));

if (!pkg.version) {
throw new Error('Missing required field "version" in package.json');
}

const main = (): void => {
const content = `version=${pkg.version}`;

// Create the dist folder if it doesn't exist
if (!fs.existsSync(distFolderLocation)) {
fs.mkdirSync(distFolderLocation);
}

// Write the output file
const file = path.resolve(distFolderLocation, OUTPUT_FILE_NAME);
fs.writeFileSync(file, content);

// eslint-disable-next-line no-console
console.log(`Wrote ${content} to ${file} was successful`);
};

main();
Loading

0 comments on commit f89b784

Please sign in to comment.