Skip to content

Commit

Permalink
Further work on build server and actions workflows (#57)
Browse files Browse the repository at this point in the history
* Add builder workflow

* workflow dispatch

* ci debug

* inputs

* fixed

* Add register

* syntax

* remove ssh

* run_id with template format

* builder-worker working

* better

* can I?

* nope

* try new build

* Add releases to builds

* sudo

* try without upgrade

* quick edits

* remove musl check

* try a release

* try and fix a release

* explicit

* add linux headers generic

* upgrade

* upgrade for real

* try docker

* relative to build dir

* fine

* missing file

* no tty

* prepare for merge

* upload

* more logs

* add install to separate section

* does this build everything?

* naming

* specific builder

* tmate

* is it explicit?

* ah

* intentional error

* register earlier

* intentional error

* intentional error

* publish complete
  • Loading branch information
maxmcd authored Dec 9, 2021
1 parent ee1d661 commit 6635c6e
Show file tree
Hide file tree
Showing 29 changed files with 531 additions and 153 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
workflow_dispatch:
inputs:
JobID:
description: "ID of the job"
required: true
Package:
description: "Package location"
required: true
Reference:
description: Version control reference, if any
required: false
name: Building Package
jobs:
build:
environment: builder
runs-on: ubuntu-latest
steps:
- name: Register
run: |
curl -X POST https://store.bramble.run/job/${{ github.event.inputs.JobID }}/register \
-H 'Content-Type: application/json' \
-d '{"RunID": ${{ github.run_id }}}'
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install
run: |
go install
- name: Build ${{ github.event.inputs.Package }} ${{ github.event.inputs.Reference }}
env:
DIGITALOCEAN_SPACES_ACCESS_ID: ${{ secrets.DIGITALOCEAN_SPACES_ACCESS_ID }}
DIGITALOCEAN_SPACES_SECRET_KEY: ${{ secrets.DIGITALOCEAN_SPACES_SECRET_KEY }}
run: |
bramble publish --upload --local ${{ github.event.inputs.Package }} ${{ github.event.inputs.Reference }}
5 changes: 5 additions & 0 deletions .github/workflows/goreleaser.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM goreleaser/goreleaser

RUN apk add gcc


24 changes: 24 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publishing Release
on:
create:
tags:
- "v*"
permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # required for goreleaser
- name: Publish release
run: |
docker build -t goreleaser -f .github/workflows/goreleaser.Dockerfile .github/workflows/
docker run \
-e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
-v $(pwd):/opt \
--workdir=/opt \
goreleaser/goreleaser release --rm-dist
7 changes: 4 additions & 3 deletions .github/workflows/go.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on: [push]
name: Test
name: Running Tests
jobs:
test:
strategy:
matrix:
go-version: [1.16.x]
go-version: [1.17.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -18,4 +18,5 @@ jobs:
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Run all tests
run: make ci_test
run: |
make ci_test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
!.vscode/settings.json
.idea
*.prof
dist
bramble
29 changes: 29 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
before:
hooks:
- go mod tidy
builds:
- ldflags:
- -s -linkmode external -extldflags "-static"
env:
- CGO_ENABLED=1
- CC=musl-gcc
goarch:
- amd64
goos:
- linux
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
amd64: x86_64
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/charmbracelet/bubbletea v0.15.0
github.com/charmbracelet/lipgloss v0.4.0
github.com/containerd/console v1.0.3
github.com/davecgh/go-spew v1.1.1
github.com/julienschmidt/httprouter v1.3.0
github.com/maxmcd/dag v0.0.0-20210909010249-5757e2034a95
github.com/mholt/archiver/v3 v3.5.0
Expand Down
34 changes: 17 additions & 17 deletions infra/builder-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Cloudflare worker TypeScript template",
"main": "dist/worker.js",
"scripts": {
"build": "webpack",
"build": "rollup -c",
"format": "prettier --write '*.{json,js}' 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"lint": "eslint --max-warnings=0 src && prettier --check '*.{json,js}' 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'",
"test": "jest --config jestconfig.json --verbose"
Expand All @@ -19,26 +19,26 @@
]
},
"devDependencies": {
"@cloudflare/workers-types": "^3.0.0",
"@octokit/types": "^6.34.0",
"@types/jest": "^26.0.23",
"@types/route-parser": "^0.1.3",
"@types/service-worker-mock": "^2.0.1",
"@typescript-eslint/eslint-plugin": "^4.16.1",
"@typescript-eslint/parser": "^4.16.1",
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",
"eslint-config-typescript": "^3.0.0",
"jest": "^27.0.1",
"prettier": "^2.3.0",
"service-worker-mock": "^2.0.5",
"ts-jest": "^27.0.1",
"ts-loader": "^9.2.2",
"typescript": "^4.3.2",
"webpack": "^5.38.1",
"webpack-cli": "^4.7.0"
"@cloudflare/workers-types": "^3.0",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.1.0",
"@rollup/plugin-typescript": "^8.2.1",
"@types/is-odd": "^3.0.0",
"@types/jest": "^26.0.23",
"isomorphic-fetch": "^3.0.0",
"jest": "^26.6.3",
"prettier": "^1.19.1",
"rollup": "^2.36.1",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-terser": "^7.0.2",
"ts-jest": "^26.5.6",
"tslib": "^2.2.0",
"typescript": "^4.2.4"
},
"dependencies": {
"node-fetch": "3.1.0",
"octokit": "^1.7.1",
"route-parser": "0.0.5"
}
Expand Down
18 changes: 18 additions & 0 deletions infra/builder-worker/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { terser } from 'rollup-plugin-terser'
// plugin-node-resolve and plugin-commonjs are required for a rollup bundled project
// to resolve dependencies from node_modules. See the documentation for these plugins
// for more details.
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import typescript from '@rollup/plugin-typescript'

export default {
input: 'src/index.ts',
output: {
exports: 'named',
format: 'es',
file: 'dist/index.mjs',
sourcemap: true,
},
plugins: [typescript(), commonjs(), nodeResolve({ browser: true }), terser()],
}
12 changes: 12 additions & 0 deletions infra/builder-worker/src/attempt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Octokit } from "octokit";

const octokit = new Octokit({ auth: "" });

(async function() {
let resp = await octokit.request("GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs", {
owner: "maxmcd",
repo: "bramble",
job_id: 4452262973,
});
console.log(resp);
})();
1 change: 1 addition & 0 deletions infra/builder-worker/src/bindings.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export {};
declare global {
const GITHUB_TOKEN: string;
const BRAMBLE: KVNamespace;
}
Loading

0 comments on commit 6635c6e

Please sign in to comment.