Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/2 enable GitHub action for cicd #4

Merged
merged 30 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
71a1e94
Added lint to worflows
MaartendeKruijf Mar 6, 2024
2f2afa1
Added build to workflows
MaartendeKruijf Mar 6, 2024
5fdeb80
Fixed build workflow
MaartendeKruijf Mar 6, 2024
c1634d5
Fixed development key
MaartendeKruijf Mar 6, 2024
3e9c024
updated ci files with correct runner
MaartendeKruijf Mar 6, 2024
065e3b0
Fixed typo in lint ci
MaartendeKruijf Mar 6, 2024
51bf8ea
fixed typo in build
MaartendeKruijf Mar 6, 2024
eb2c211
Added crosscompile
MaartendeKruijf Mar 6, 2024
ddd5c95
Added test
MaartendeKruijf Mar 6, 2024
1187018
Use bash
MaartendeKruijf Mar 6, 2024
7397b96
List dir
MaartendeKruijf Mar 6, 2024
c9f876c
Add repo to safe config in git
MaartendeKruijf Mar 6, 2024
4f7a2a0
Make repo safe for lint
MaartendeKruijf Mar 6, 2024
656b9b9
Upload artifacts
MaartendeKruijf Mar 6, 2024
12e8e3e
Name artifact with gitsha
MaartendeKruijf Mar 6, 2024
133c268
Updated to checkout v4
MaartendeKruijf Mar 6, 2024
892036c
Renamed compile to artifacts and included dockerbuild
MaartendeKruijf Mar 6, 2024
9745fcd
Updated workflow
MaartendeKruijf Mar 6, 2024
1a65ff5
Added file . to docker build command
MaartendeKruijf Mar 6, 2024
6612ced
Added artifact download
MaartendeKruijf Mar 6, 2024
1e735eb
Move files to bin folder
MaartendeKruijf Mar 6, 2024
dcf8471
Fixed typo in build
MaartendeKruijf Mar 6, 2024
763e0e1
add bin folder
MaartendeKruijf Mar 6, 2024
aae9444
Moved test to unittest, integration test and manual tests
MaartendeKruijf Mar 6, 2024
b96486c
Changed to ci-test
MaartendeKruijf Mar 6, 2024
40dd0b4
Updated description
MaartendeKruijf Mar 6, 2024
f5ea0e3
Moved build lint test to ci.yml
MaartendeKruijf Mar 6, 2024
6491e31
Fixed swagger docs build
MaartendeKruijf Mar 6, 2024
32507d5
Fixed ci linting
MaartendeKruijf Mar 6, 2024
ee7847a
Install swaggo
MaartendeKruijf Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Artifacts

on:
pull_request:
branches: [ master, development ]

jobs:
compile:
name: Cross compile binaries
runs-on: ubuntu-latest
container:
image: golangci/golangci-lint:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Make repo safe
run: git config --global --add safe.directory /__w/SOARCA/SOARCA

- name: Install swaggo
run: go install github.com/swaggo/swag/cmd/swag@latest

- name: Build with make
run: |
go install github.com/swaggo/swag/cmd/swag@latest
go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest
make compile
make sbom

- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ github.sha }}
path: bin/*
retention-days: 1

docker-build:
needs: compile
name: Build docker image
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Make repo safe
run: git config --global --add safe.directory /__w/SOARCA/SOARCA

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Download bin
uses: actions/download-artifact@v4
with:
pattern: ${{ github.sha }}

- name: Move files to bin folder
run: |
mkdir -p bin
mv ${{ github.sha }}/* ./bin/

- name: Build image
run: |
export VERSION=$(git describe --tags --dirty)
echo $VERSION
docker build --build-arg VERSION -t $VERSION .
64 changes: 64 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Ci

on:
pull_request:
branches: [ master, development ]

jobs:
build:
name: Build binary
runs-on: ubuntu-latest
container:
image: golangci/golangci-lint:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install swaggo
run: go install github.com/swaggo/swag/cmd/swag@latest

- name: Build with make
run: make build

lint:
name: Lint go code with golangci
runs-on: ubuntu-latest
container:
image: golangci/golangci-lint:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Make repo safe
run: git config --global --add safe.directory /__w/SOARCA/SOARCA
- name: Install swaggo
run: go install github.com/swaggo/swag/cmd/swag@latest
- name: lint
run: |
ls -la
make lint
shell: bash

test:
name: Run ci-tests
runs-on: ubuntu-latest
container:
image: golang:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run tests
run: |
apt update
apt install openssh-server -y
useradd sshtest
echo "sshtest:pdKY77qNxpI5MAizirtjCVOcm0KFKIs" | chpasswd
service ssh start
make ci-test

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins/*
build/*
!build/build.md
bin/*
swaggerdocs/*
test/cacao/flatfile-db-example.json
test/routes/__debug_bin2988553005

Expand Down
Loading