Skip to content

Commit b96b96d

Browse files
Feature/2 enable GitHub action for cicd (#4)
1 parent d5ea320 commit b96b96d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+310
-2532
lines changed

.github/workflows/artifacts.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Artifacts
2+
3+
on:
4+
pull_request:
5+
branches: [ master, development ]
6+
7+
jobs:
8+
compile:
9+
name: Cross compile binaries
10+
runs-on: ubuntu-latest
11+
container:
12+
image: golangci/golangci-lint:latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Make repo safe
19+
run: git config --global --add safe.directory /__w/SOARCA/SOARCA
20+
21+
- name: Install swaggo
22+
run: go install github.com/swaggo/swag/cmd/swag@latest
23+
24+
- name: Build with make
25+
run: |
26+
go install github.com/swaggo/swag/cmd/swag@latest
27+
go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest
28+
make compile
29+
make sbom
30+
31+
- name: 'Upload Artifact'
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: ${{ github.sha }}
35+
path: bin/*
36+
retention-days: 1
37+
38+
docker-build:
39+
needs: compile
40+
name: Build docker image
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout Code
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
- name: Make repo safe
48+
run: git config --global --add safe.directory /__w/SOARCA/SOARCA
49+
50+
- name: Set up QEMU
51+
uses: docker/setup-qemu-action@v3
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v3
54+
55+
- name: Download bin
56+
uses: actions/download-artifact@v4
57+
with:
58+
pattern: ${{ github.sha }}
59+
60+
- name: Move files to bin folder
61+
run: |
62+
mkdir -p bin
63+
mv ${{ github.sha }}/* ./bin/
64+
65+
- name: Build image
66+
run: |
67+
export VERSION=$(git describe --tags --dirty)
68+
echo $VERSION
69+
docker build --build-arg VERSION -t $VERSION .

.github/workflows/ci.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Ci
2+
3+
on:
4+
pull_request:
5+
branches: [ master, development ]
6+
7+
jobs:
8+
build:
9+
name: Build binary
10+
runs-on: ubuntu-latest
11+
container:
12+
image: golangci/golangci-lint:latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install swaggo
20+
run: go install github.com/swaggo/swag/cmd/swag@latest
21+
22+
- name: Build with make
23+
run: make build
24+
25+
lint:
26+
name: Lint go code with golangci
27+
runs-on: ubuntu-latest
28+
container:
29+
image: golangci/golangci-lint:latest
30+
steps:
31+
- name: Checkout Code
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
- name: Make repo safe
36+
run: git config --global --add safe.directory /__w/SOARCA/SOARCA
37+
- name: Install swaggo
38+
run: go install github.com/swaggo/swag/cmd/swag@latest
39+
- name: lint
40+
run: |
41+
ls -la
42+
make lint
43+
shell: bash
44+
45+
test:
46+
name: Run ci-tests
47+
runs-on: ubuntu-latest
48+
container:
49+
image: golang:latest
50+
steps:
51+
- name: Checkout Code
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
56+
- name: Run tests
57+
run: |
58+
apt update
59+
apt install openssh-server -y
60+
useradd sshtest
61+
echo "sshtest:pdKY77qNxpI5MAizirtjCVOcm0KFKIs" | chpasswd
62+
service ssh start
63+
make ci-test
64+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ plugins/*
99
build/*
1010
!build/build.md
1111
bin/*
12+
swaggerdocs/*
1213
test/cacao/flatfile-db-example.json
1314
test/routes/__debug_bin2988553005
1415

0 commit comments

Comments
 (0)