Skip to content

Commit

Permalink
MVP
Browse files Browse the repository at this point in the history
Some MVP changes
- Detect change and reload on-disk DDB file.
- Fix e2e tests (more to be added).
- CI is able to build for linux (amd64 and arm64), macos, windows.
- some type handling (thanks to https://github.com/snakedotdev/grafana-duckdb-datasource).
- Initial README.md
- Add logo and screenshot.
  • Loading branch information
hrl20 authored Jan 4, 2025
2 parents 4044780 + 1ad8c22 commit e8a9648
Show file tree
Hide file tree
Showing 22 changed files with 485 additions and 338 deletions.
191 changes: 170 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,170 @@ name: CI
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

permissions: read-all

jobs:
build-linux-amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: magefile/mage-action@v3
with:
version: latest
args: coverage
- uses: magefile/mage-action@v3
with:
version: latest
args: -v build:Linux
- name: Upload Linux AMD64 artifact
uses: actions/upload-artifact@v4
with:
name: linux-amd64-dist
path: dist/

build-linux-arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: linux/arm64

- name: Create temporary Dockerfile
run: |
cat > Dockerfile << 'EOF'
FROM arm64v8/golang:1.23
RUN go install github.com/magefile/mage@latest
RUN mage -init
RUN apt-get update && apt-get install -y \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu
RUN rm -rf /var/lib/apt/lists/*
# Address Issue: error obtaining VCS status: exit status 128
# Use -buildvcs=false to disable VCS stamping.
ENV GOFLAGS=-buildvcs=false
WORKDIR /repo
EOF
- name: Build and run Container
shell: sh

run: |
cat > run.sh << 'EOF'
#!/bin/sh
mage coverage
mage -v build:LinuxARM64
EOF
cat run.sh
chmod +x run.sh
docker build --platform linux/arm64 -t go-arm64 .
docker run --platform linux/arm64 -v `pwd`:/repo --name go-arm64 go-arm64 ./run.sh
- name: Upload Linux ARM64 artifact
uses: actions/upload-artifact@v4
with:
name: linux-arm64-dist
path: dist/

build-macos-arm64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: install mage
run: |
go install github.com/magefile/mage@latest
mage coverage
mage -v build:DarwinARM64
- name: Upload macOS ARM64 artifact
uses: actions/upload-artifact@v4
with:
name: macos-arm64-dist
path: dist/

build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: magefile/mage-action@v3
with:
version: latest
args: coverage
- uses: magefile/mage-action@v3
with:
version: latest
args: -v build:Windows
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-dist
path: dist/

generate-manifest:
needs: [build-linux-amd64, build-macos-arm64, build-windows]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts

- name: Prepare dist directory
run: |
mkdir -p dist
cp -r all-artifacts/*/* dist/
- uses: magefile/mage-action@v3
with:
version: latest
args: -v build:GenerateManifestFile
- name: Upload final artifacts with manifest
uses: actions/upload-artifact@v4
with:
name: final-dist
path: dist/


build:
name: Build, lint and unit tests
runs-on: ubuntu-latest
needs: generate-manifest
outputs:
plugin-id: ${{ steps.metadata.outputs.plugin-id }}
plugin-version: ${{ steps.metadata.outputs.plugin-version }}
Expand All @@ -27,15 +178,17 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Check types
run: npm run typecheck
- name: Lint
Expand All @@ -52,26 +205,15 @@ jobs:
then
echo "has-backend=true" >> $GITHUB_OUTPUT
fi
- name: Setup Go environment
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: actions/setup-go@v5
with:
go-version: '1.21'
go-version: '1.23'

- name: Test backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: coverage

- name: Build backend
if: steps.check-for-backend.outputs.has-backend == 'true'
uses: magefile/mage-action@v3
with:
version: latest
args: -v build:Linux build:GenerateManifestFile
- name: Download backend dist directory
run: |
mkdir -p dist
cp -r all-artifacts/final-dist/* dist/
- name: Check for E2E
id: check-for-e2e
Expand All @@ -98,11 +240,16 @@ jobs:
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
- name: Add execute permissions on binary
if: needs.build.outputs.has-backend == 'true'
run: |
chmod +x ./dist/gpx_*
- name: Package plugin
id: package-plugin
run: |
mv dist ${{ steps.metadata.outputs.plugin-id }}
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
zip -r ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }}
- name: Archive Build
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -147,6 +294,8 @@ jobs:
- name: Execute permissions on binary
if: needs.build.outputs.has-backend == 'true'
run: |
ls
ls dist/
chmod +x ./dist/gpx_*
- name: Setup Node.js environment
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}
Copyright 2024 MotherDuck

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit e8a9648

Please sign in to comment.