Skip to content

Commit 3fd5e2d

Browse files
author
lfbdev
committed
python and nodejs action flow
format config file
1 parent aae8e6d commit 3fd5e2d

File tree

5 files changed

+105
-5
lines changed

5 files changed

+105
-5
lines changed

examples/config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ tools:
99
name: go
1010
version: "1.17"
1111
branch: master
12+
##for python config
13+
#- name: githubactions
14+
# version: 0.0.1
15+
# options:
16+
# owner: lfbdev
17+
# repo: spotipy
18+
# language:
19+
# name: python
20+
# version: "3"
21+
# branch: master
22+
##for nodejs config
23+
#- name: githubactions
24+
# version: 0.0.1
25+
# options:
26+
# owner: lfbdev
27+
# repo: lowdb
28+
# language:
29+
# name: nodejs
30+
# version: "9"
31+
# branch: main
1232
- name: argocd
1333
version: 0.0.1
1434
options:

internal/pkg/githubactions/githubactions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (ga *GithubActions) AddWorkflow(workflow *Workflow) error {
5858
opts := &github.RepositoryContentFileOptions{
5959
Message: github.String(workflow.commitMessage),
6060
Content: []byte(workflow.workflowContent),
61-
Branch: github.String("master"),
61+
Branch: github.String(ga.options.Branch),
6262
}
6363

6464
log.Printf("creating github actions Workflow %s...\n", workflow.workflowFileName)
@@ -92,7 +92,7 @@ func (ga *GithubActions) DeleteWorkflow(workflow *Workflow) error {
9292
opts := &github.RepositoryContentFileOptions{
9393
Message: github.String(workflow.commitMessage),
9494
Content: []byte(workflow.workflowContent),
95-
Branch: github.String("master"),
95+
Branch: github.String(ga.options.Branch),
9696
}
9797

9898
log.Printf("deleting github actions Workflow %s...\n", workflow.workflowFileName)

internal/pkg/githubactions/install.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package githubactions
22

3+
import "fmt"
4+
35
// Install sets up GitHub Actions workflows.
46
func Install(options *map[string]interface{}) (bool, error) {
57
githubActions, err := NewGithubActions(options)
@@ -10,6 +12,9 @@ func Install(options *map[string]interface{}) (bool, error) {
1012
language := githubActions.GetLanguage()
1113
ws := defaultWorkflows.GetWorkflowByNameVersionTypeString(language.String())
1214

15+
fmt.Println("lang is ", language.Name, language.Version, language.String())
16+
fmt.Println("ws is ", ws)
17+
1318
for _, pipeline := range ws {
1419
err := githubActions.AddWorkflow(pipeline)
1520
if err != nil {
Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
package nodejs
22

3-
var PrBuilder = ``
3+
var PrBuilder = `
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [12.x, 14.x, 16.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- run: npm ci
29+
- run: npm run build --if-present
30+
- run: npm test
31+
`
432

533
var MasterBuilder = ``
Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
package python
22

3-
var PrBuilder = ``
3+
var PrBuilder = `
4+
name: "Pull Request Workflow"
5+
on:
6+
pull_request:
7+
types: [ready_for_review]
48
5-
var MasterBuilder = ``
9+
jobs:
10+
# Enforces the update of a changelog file on every pull request
11+
changelog:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- uses: dangoslen/[email protected]
16+
with:
17+
changeLogPath: 'CHANGELOG.md'
18+
skipLabel: 'skip-changelog'
19+
`
20+
21+
var MasterBuilder = `
22+
name: Tests
23+
24+
on: [push, pull_request]
25+
26+
jobs:
27+
build:
28+
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: [2.7, 3.5, 3.6, 3.7]
33+
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: Set up Python ${{ matrix.python-version }}
37+
uses: actions/setup-python@v1
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install .[test]
44+
- name: Lint with flake8
45+
run: |
46+
pip install -Iv enum34==1.1.6 # https://bitbucket.org/stoneleaf/enum34/issues/27/enum34-118-broken
47+
pip install flake8
48+
flake8 . --count --show-source --statistics
49+
- name: Run unit tests
50+
run: |
51+
python -m unittest discover -v tests/unit
52+
`

0 commit comments

Comments
 (0)