Skip to content

Commit

Permalink
Refactor the action code (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam authored Jun 19, 2024
1 parent 84b3209 commit bc312d1
Show file tree
Hide file tree
Showing 19 changed files with 905 additions and 6,454 deletions.
17 changes: 17 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.base.schema.json",
"name": "default",
"image": "node:20-bookworm",
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/sshd:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"streetsidesoftware.code-spell-checker"
]
}
},
"postCreateCommand": "npm install"
}
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[{*.yml,*.yaml}]
ij_any_spaces_within_braces = false
ij_any_spaces_within_brackets = false

[Makefile]
indent_style = tab
18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

3 changes: 2 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Docs: <https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/customizing-dependency-updates>
# yaml-language-server: $schema=https://json.schemastore.org/dependabot-2.0.json
# docs: https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/customizing-dependency-updates

version: 2

Expand Down
13 changes: 13 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-release-config.json
# docs: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes

changelog:
categories:
- title: 🛠 Fixes
labels: [type:fix, type:bug]
- title: 🚀 Features
labels: [type:feature, type:feature_request]
- title: 📦 Dependency updates
labels: [dependencies]
- title: Other Changes
labels: ['*']
9 changes: 6 additions & 3 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: dependabot
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: 🤖 Dependabot

on:
pull_request: {}
Expand All @@ -9,15 +12,15 @@ permissions:

jobs:
dependabot: # https://tinyurl.com/e69djmen
name: Enable auto-merge for Dependabot PRs
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- uses: dependabot/fetch-metadata@v2
id: metadata
with: {github-token: "${{ secrets.GITHUB_TOKEN }}"}

- name: Enable auto-merge for Dependabot PRs
if: ${{ contains(fromJSON('["version-update:semver-minor", "version-update:semver-patch"]'), steps.metadata.outputs.update-type) }}
- if: ${{ contains(fromJSON('["version-update:semver-minor", "version-update:semver-patch"]'), steps.metadata.outputs.update-type) }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
name: release
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: 🚀 Release

on:
release: # Docs: <https://help.github.com/en/articles/events-that-trigger-workflows#release-event-release>
types: [published]

jobs:
update-git-tag: # Reason: <https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations>
name: 🚀 Update latest major git tag
name: Update latest major git tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: gacts/github-slug@v1
id: slug

- name: Setup git
env: {REPO_PATH: "${{ github.repository_owner }}/${{ github.event.repository.name }}"}
- {uses: gacts/github-slug@v1, id: slug}
- env: {REPO_PATH: "${{ github.repository_owner }}/${{ github.event.repository.name }}"}
run: |
git config --local user.email '[email protected]'
git config --local user.name "${{ github.actor }}"
git remote set-url origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/$REPO_PATH.git"
- name: Update major tag
env: {VERSION: "${{ steps.slug.outputs.version-major }}"}
run: |
git tag -fa "v$VERSION" -m "Update v$VERSION tag (using GitHub actions)"
git push --set-upstream origin "v$VERSION" --force
- name: Update minor tag
env: {VERSION: "${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}"}
run: |
Expand Down
49 changes: 17 additions & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: tests
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# docs: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

name: 🧪 Tests

on:
push:
Expand All @@ -12,54 +15,42 @@ concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env: {FORCE_COLOR: 'true'}

jobs:
gitleaks:
name: 🔐 Check for GitLeaks
name: Check for GitLeaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with: {fetch-depth: 0}

- {uses: actions/checkout@v4, with: {fetch-depth: 0}}
- uses: gacts/gitleaks@v1

eslint:
name: 🧪 Run ESLint
name: Run code linter
runs-on: ubuntu-latest
env: {FORCE_COLOR: 'true'}
steps:
- uses: actions/checkout@v4

- uses: gacts/setup-node-with-cache@v1
with: {node-version: 20}

- run: npm ci

- {uses: gacts/setup-node-with-cache@v1, with: {node-version: 20}}
- run: npm install
- run: npm run lint

dist-built:
name: 🧪 Check distributive built state
name: Check distributive built state
runs-on: ubuntu-latest
outputs:
dist-changed: ${{ steps.state.outputs.changed }}
env: {FORCE_COLOR: 'true'}
steps:
- uses: actions/checkout@v4

- uses: gacts/setup-node-with-cache@v1
with: {node-version: 20}

- run: npm ci

- {uses: gacts/setup-node-with-cache@v1, with: {node-version: 20}}
- run: npm install
- run: npm run build

- uses: actions/upload-artifact@v4
with: {name: dist, path: ./dist/, retention-days: 1}

- id: state
run: echo "changed=`git diff --diff-filter=ACMUXTR --name-only | grep dist/ > /dev/null && echo 'true' || echo 'false'`" >> $GITHUB_OUTPUT

commit-and-push-fresh-dist:
name: 🏗️ Commit and push fresh distributive
name: Commit and push fresh distributive
needs: [dist-built]
if: ${{ needs.dist-built.outputs.dist-changed == 'true' }}
runs-on: ubuntu-latest
Expand All @@ -68,13 +59,10 @@ jobs:
pull-requests: write
steps:
- uses: actions/checkout@v4

- uses: actions/download-artifact@v4
with: {name: dist, path: ./dist/}

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Automatic distributive rebuild
with: {commit_message: Automatic distributive rebuild}

run-this-action: # non-existing files will not generate an error
name: 🚀 Run (${{ matrix.runs-on }}, ${{ matrix.version }})
Expand All @@ -86,10 +74,7 @@ jobs:
version: [1.8.0, 2.0.0, 3.0.0, 4.0.0, 4.1.0, 4.3.0, latest]
steps:
- uses: actions/checkout@v4

- name: Run this action
uses: ./
with:
version: ${{ matrix.version }}

with: {version: '${{ matrix.version }}'}
- run: hurl --version
59 changes: 0 additions & 59 deletions CHANGELOG.md

This file was deleted.

35 changes: 19 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
#!/usr/bin/make
# Makefile readme (ru): <https://blog.hook.sh/nix/makefile-full-doc/>
# Makefile readme (en): <https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents>
# Makefile readme: <https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents>

SHELL = /bin/bash
DC_RUN_ARGS = --rm --user "$(shell id -u):$(shell id -g)"
.DEFAULT_GOAL := build
.MAIN := build

.PHONY : help install shell lint test build
.DEFAULT_GOAL : help

help: ## Show this help
@printf "\033[33m%s:\033[0m\n" 'Available commands'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[32m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
NODE_IMAGE = node:20-alpine
RUN_ARGS = --rm -v "$(shell pwd):/src:rw" \
-t --workdir "/src" \
-u "$(shell id -u):$(shell id -g)" \
-e "NPM_CONFIG_UPDATE_NOTIFIER=false" \
-e PATH="$$PATH:/src/node_modules/.bin" $(NODE_IMAGE)

.PHONY: install
install: ## Install all dependencies
docker compose run $(DC_RUN_ARGS) node npm install
docker run $(RUN_ARGS) npm install

.PHONY: shell
shell: ## Start shell into a container with node
docker compose run $(DC_RUN_ARGS) node sh
docker run -e "PS1=\[\033[1;34m\]\w\[\033[0;35m\] \[\033[1;36m\]# \[\033[0m\]" -i $(RUN_ARGS) sh

lint: ## Execute provided linters
docker compose run $(DC_RUN_ARGS) node npm run lint
.PHONY: lint
lint: ## Run lint
docker run $(RUN_ARGS) npm run lint

build: ## Build frontend
docker compose run $(DC_RUN_ARGS) node npm run build
.PHONY: build
build: install ## Build the extension and pack it into a zip file
docker run $(RUN_ARGS) npm run build
Loading

0 comments on commit bc312d1

Please sign in to comment.