Skip to content

Commit

Permalink
feat: change building system to rollup, compiling linter into a binary
Browse files Browse the repository at this point in the history
  • Loading branch information
zavoloklom committed Nov 14, 2024
1 parent 56d57da commit 74fa0e3
Show file tree
Hide file tree
Showing 74 changed files with 4,106 additions and 852 deletions.
49 changes: 49 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# OS
.DS_Store

# Git
.git/
.gitignore

# Github
.github/

# Docker
Dockerfile

# Documentation
/documentation
/docs

# Dependencies
/node_modules

# Compiled output and runtime
/dist
/bin
/pkg
/.tsimp
/sea-prep.blob
/dclint

# Tests
/coverage

# Other
Makefile
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ module.exports = {
'unicorn/switch-case-braces': [2, 'avoid'],
'unicorn/import-style': [2, {"styles": {"node:path": {"named": true, "default": false}}}]
},
'ignorePatterns': ['node_modules', 'dist', '.tsimp', 'coverage', 'bin'],
'ignorePatterns': ['node_modules', 'dist', '.tsimp', 'coverage', 'bin', 'rollup*config*js'],
};
173 changes: 158 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@ on:
- '**'

jobs:
build:
tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20.17.0'
node-version: '20.18.0'

- name: Install dependencies
run: npm ci

- name: Build the project
run: npm run build

- name: Build SEA
run: docker run --rm -v "$PWD":/app -w /app node:20.18.0-alpine ./scripts/generate-sea.sh ./pkg/dclint

- name: Run linter
run: npm run lint

Expand All @@ -39,12 +42,96 @@ jobs:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: wget -qO - https://coverage.codacy.com/get.sh | bash -s -- report -r ./coverage/cobertura-coverage.xml

- name: Upload tests artifacts
uses: actions/upload-artifact@v4
with:
name: tests-artifacts
path: |
./dist
./bin
debug:
runs-on: ubuntu-latest
needs: tests
strategy:
matrix:
node-version: [18, 20, 22, 23]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: tests-artifacts
path: ./

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci --omit=dev

- name: Run debug:bin
run: npm run debug:bin

build:
runs-on: ubuntu-latest
needs:
- tests
- debug
# if: github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.18.0'

- name: Install dependencies
run: npm ci

- name: Generate new version
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release --dry-run --no-ci

- name: Build the project
run: |
export VERSION=$(cat .VERSION)
npm run build
- name: Set up QEMU for multi-arch
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm64

- name: Build SEA for Alpine amd64
run: docker run --rm --platform linux/amd64 -v "$PWD":/app -w /app node:20.18.0-alpine ./scripts/generate-sea.sh ./pkg/dclint-alpine-amd64

- name: Build SEA for Bullseye amd64
run: docker run --rm --platform linux/amd64 -v "$PWD":/app -w /app node:20.18.0-bullseye ./scripts/generate-sea.sh ./pkg/dclint-bullseye-amd64

- name: Build SEA for Alpine arm64
run: docker run --rm --platform linux/arm64 -v "$PWD":/app -w /app node:20.18.0-alpine ./scripts/generate-sea.sh ./pkg/dclint-alpine-arm64

- name: Build SEA for Bullseye arm64
run: docker run --rm --platform linux/arm64 -v "$PWD":/app -w /app node:20.18.0-bullseye ./scripts/generate-sea.sh ./pkg/dclint-bullseye-arm64

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/main'
with:
name: build-artifacts
path: ./dist
path: |
./dist
./bin
./pkg
release:
runs-on: ubuntu-latest
Expand All @@ -53,18 +140,18 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
path: ./dist
path: ./

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '20.17.0'
node-version: '20.18.0'

- name: Install dependencies
run: npm ci
Expand All @@ -75,6 +162,43 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release

# Upload binary files to GitHub Release
- name: Upload Alpine Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-alpine-amd64
asset_name: dclint-alpine-amd64
asset_content_type: application/octet-stream

- name: Upload Bullseye Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-bullseye-amd64
asset_name: dclint-bullseye-amd64
asset_content_type: application/octet-stream

- name: Upload Alpine ARM64 Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-alpine-arm64
asset_name: dclint-alpine-arm64
asset_content_type: application/octet-stream

- name: Upload Bullseye ARM64 Binary
uses: actions/upload-release-asset@v1
if: steps.release.outputs.new_release == 'true'
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ./pkg/dclint-bullseye-arm64
asset_name: dclint-bullseye-arm64
asset_content_type: application/octet-stream

- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -91,7 +215,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download release artifacts
uses: actions/download-artifact@v4
Expand All @@ -111,18 +235,36 @@ jobs:
echo "BUILD_REVISION=$BUILD_REVISION" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
install: true

- name: Log in to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
# Build and push the Alpine version
- name: Build and push Alpine version
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/dclint:alpine
${{ secrets.DOCKERHUB_USERNAME }}/dclint:latest-alpine
${{ secrets.DOCKERHUB_USERNAME }}/dclint:${{ env.BUILD_VERSION }}-alpine
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_VERSION=${{ env.BUILD_VERSION }}
BUILD_REVISION=${{ env.BUILD_REVISION }}
target: alpine-version

# Build and push the Scratch version
- name: Build and push Scratch version
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand All @@ -134,3 +276,4 @@ jobs:
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_VERSION=${{ env.BUILD_VERSION }}
BUILD_REVISION=${{ env.BUILD_REVISION }}
target: scratch-version
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@

# Build
/dist
/bin
/pkg

# Runtime
/.tsimp

# Generated files
/sea-prep.blob
/.VERSION
11 changes: 9 additions & 2 deletions .markdownlint.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
module.exports = {
'default': true,
'no-hard-tabs': false,
'whitespace': false,
'MD003': {
'style': 'atx',
},
'MD004': {
'style': 'dash',
},
'MD007': {
'indent': 2,
},
'MD013': {
'line_length': 120,
'ignore_code_blocks': true,
'ignore_urls': true,
'code_blocks': false,
'tables': false,
},
'MD024': {
Expand Down
Loading

0 comments on commit 74fa0e3

Please sign in to comment.