Skip to content

Commit

Permalink
build: add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebedo committed Jan 28, 2024
1 parent c8cdac1 commit bc9e1c9
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/commit_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Commit Checks

on:
workflow_call:
inputs:
base_sha:
description: 'Base SHA to check from'
required: true
type: string
head_sha:
description: 'Head SHA to check until'
required: true
type: string

jobs:
commit_messages_checks:
name: Commit messages checks
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.7.0
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Check commit messages
run: devbox run -- cz check --rev-range ${{ inputs.base_sha }}..${{ inputs.head_sha }}

code_lint_checks:
name: Code lint checks
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.7.0
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Lint code
run: devbox run lint

test_checks:
name: Test checks
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.7.0
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Run tests
run: devbox run test
15 changes: 15 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: main branch workflow

on:
push:
branches:
- master

jobs:
commit_checks:
name: Commit checks
uses: ./.github/workflows/commit_checks.yml
with:
base_sha: ${{ github.event.before }}
head_sha: ${{ github.event.after }}

15 changes: 15 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: PR workflow

on:
pull_request:
branches:
- master

jobs:
commit_checks:
name: Commit checks
uses: ./.github/workflows/commit_checks.yml
with:
base_sha: ${{ github.event.pull_request.base.sha }}
head_sha: ${{ github.event.pull_request.head.sha }}

30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release workflow

on:
push:
branches-ignore:
- '**'
tags:
- 'v*'

permissions:
contents: write

jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4

- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.7.0
with:
devbox-version: 0.8.5
enable-cache: 'true'

- name: Publish release
run: devbox run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/release.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Release workflow

on:
push:
tags:
- "v*.*.*"

jobs:
release:
runs-on: ubuntu-latest
steps:

- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
changelog_increment_filename: CHANGELOG.md

- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: "CHANGELOG.md"
tag_name: ${{ env.REVISION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89 changes: 89 additions & 0 deletions domaingraph.go.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
package servers

import (
"github.com/gyuho/goraph"
"strings"
"fmt"
)


type DomainGraph struct {
graph goraph.Graph
roots []goraph.Node
}


func NewDomainGraph() *DomainGraph {
res := &DomainGraph {}
res.graph = goraph.NewGraph()
return res
}


//
//type DomainGraphNode {
// name String
// children []*DomainGraphNode
//}
//
//
func (g *DomainGraph) AddDomain(domain string) {
splitted := strings.Split(domain,".")
var parent goraph.Node = nil
for i := len(splitted)-1; i >= 0; i-- {
var curComp = splitted[i]
node, err := g.graph.GetNode(goraph.StringID(curComp))
if err != nil {
fmt.Printf("Node %s does not exist, add it\n", curComp)
node = goraph.NewNode(curComp)
g.graph.AddNode(node)
}
if parent == nil {
parent = node
g.roots = append(g.roots,node)
} else {
g.graph.AddEdge(parent.ID(),node.ID(),1)
fmt.Printf("Add edge from %s to %s \n", parent, node)
}
}
}

func (g *DomainGraph) Display() {
for _, c := range g.roots {
g.displayNode(c)
}
}

func (g *DomainGraph) displayNode(curNode goraph.Node) {
fmt.Println("Node: %s visited", curNode.ID())
children, err := g.graph.GetTargets(curNode.ID())
fmt.Printf("Number of children: %i\n", len(children))
if err == nil {
for _,c := range children {

g.displayNode(c)
}
}
}
//
//
//func (g DomainGraph) RemoveDomain(domain String) {
//
//}
//
//func (g DomainGraph) getNodes(query String) []*DomainGraphNode {
// splittedQuery = strings.Split(strings.ToLower(query), ".")
//}
//
//func resolveDomain(query []String, n *DomainGraphNode)
//{
//}
//
//func (n DomainGraphNode) Name() String {
// return n.name
//}
//
//func (n DomainGraphNode) Children() []*DomainGraphNode {
// return n.children
//}*/

0 comments on commit bc9e1c9

Please sign in to comment.