Skip to content

Commit

Permalink
Merge pull request #1 from RicYaben/staging
Browse files Browse the repository at this point in the history
Revamping riotpot with latest changes
  • Loading branch information
RicYaben authored Jan 9, 2023
2 parents eaa82c1 + c908e02 commit d3830e7
Show file tree
Hide file tree
Showing 179 changed files with 47,626 additions and 2,466 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Nightly
on:
schedule:
- cron: "0 0 * * *"

jobs:
riotpot:
strategy:
matrix:
go-version: [1.18]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: staging
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build application
run: make build-all

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: riotpot
path: bin
if-no-files-found: error

ui:
defaults:
run:
working-directory: ./ui
strategy:
matrix:
node-version: [19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: riotpot
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: staging
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: "npm"
node-version: ${{ matrix.node-version }}
cache-dependency-path: "ui/package-lock.json"

# Create the build folder
- run: npm ci
- run: CI=false npm run build --if-present

# Move the new build folder so we can add it as a folder to the artifact
- name: Move build
working-directory: ./ui
run: |
mkdir -p riotpot-ui/ui
mv build/* riotpot-ui/ui
# Create a release
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: riotpot
path: ui/riotpot-ui
if-no-files-found: error

release:
permissions:
contents: write
needs: ui
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
id: download
with:
path: artifacts

- name: Zip content
working-directory: artifacts
run: zip -r riotpot.zip riotpot

# Nightly
- name: Release Nightly
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: nightly
files: artifacts/riotpot.zip
prerelease: true
137 changes: 100 additions & 37 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,112 @@
name: release
name: Releaser

on:
push:
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
- "**.md"

jobs:
build:
riotpot:
strategy:
matrix:
go-version: [1.16]
go-version: [1.18]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --force --tags

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build application
run: make build-all

- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: riotpot
path: bin
if-no-files-found: error

ui:
defaults:
run:
working-directory: ./ui
strategy:
matrix:
node-version: [19.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
needs: riotpot
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: "npm"
node-version: ${{ matrix.node-version }}
cache-dependency-path: "ui/package-lock.json"

# Create the build folder
- run: npm ci
- run: CI=false npm run build --if-present

# Move the new build folder so we can add it as a folder to the artifact
- name: Move build
working-directory: ./ui
run: |
mkdir -p riotpot-ui/ui
mv build/* riotpot-ui/ui
# Create a release
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: riotpot
path: ui/riotpot-ui
if-no-files-found: error

release:
permissions:
contents: write
needs: ui
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
id: download
with:
path: artifacts

- name: Zip content
working-directory: artifacts
run: zip -r riotpot.zip riotpot

- name: Checkout
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
if: github.event_name == 'push' && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest')
run: cd cmd/riotpot && go build -o bin/ -v

# Autoreleaser https://goreleaser.com/ci/actions/
# it MAY need secrets! more: https://docs.github.com/en/actions/reference/encrypted-secrets
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
workdir: cmd/riotpot
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release Main Latest
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/') && github.ref_name == 'main' && github.event_name == 'pull_request'
with:
name: latest
files: artifacts/riotpot.zip
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ bin/
.idea/
.vscode/
.DS_Store
.dccache
## VSCode workspace file
workspace*.code-*

Expand All @@ -33,11 +34,8 @@ workspace*.code-*
# TCPdump
/tcpdump/

# Keys for the SSH connections
configs/keys/*

# whatever the rules are, include all the `.md` files
!*.md

# Remove the riotpot binary
riotpot
# Remove the local samples
local
9 changes: 0 additions & 9 deletions .gitmodules

This file was deleted.

49 changes: 28 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
SHELL := /bin/bash

# Makefile
APPNAME=riotpot
CURRENT_DIR=`pwd`
PACKAGE_DIRS=`go list -e ./... | egrep -v "binary_output_dir|.git|mocks"`
DEPLOY=deployments/
DOCKER=build/docker/
PLUGINS_DIR=pkg/plugin
EXCLUDE_PLUGINS= sshd

##
exclude_plugins_list := $(subst ., ,$(EXCLUDE_PLUGINS))

# docker cmd below
.PHONY: docker-build-doc riotpot-doc riotpot-up riotpot-prod-up riotpot-prod-down riotpot-build riotpot-build-plugins riotpot-builder
.PHONY: docker-build-doc docker-doc-up up down up-all build build-plugins build-all ui
docker-build-doc:
docker build -f $(DOCKER)Dockerfile.documentation . -t $(APPNAME)/v1
riotpot-doc: docker-build-doc
docker-doc-up: docker-build-doc
docker run -p 6060:6060 -it $(APPNAME)/v1
riotpot-up:
docker-compose -p riotpot -f ${DEPLOY}docker-compose.yml up -d --build
riotpot-down:
docker-compose -p riotpot -f ${DEPLOY}docker-compose.yml down -v
riotpot-prod-up:
docker-compose -p riotpot -f ${DEPLOY}docker-compose.prod.yml up -d --build
riotpot--prod-down:
docker-compose -p riotpot -f ${DEPLOY}docker-compose.prod.yml down -v
riotpot-all:
up:
docker-compose -p riotpot -f ${DOCKER}docker-compose.yaml up -d --build
down:
docker-compose -p riotpot -f ${DOCKER}docker-compose.yaml down -v
up-all:
riotpot-doc
riotpot-up
riotpot-build:
go build -o riotpot cmd/riotpot/main.go;
riotpot-build-plugins: $(PLUGINS_DIR)/*
build:
go build -gcflags='all=-N -l' -o ./bin/ ./cmd/riotpot/.
build-plugins: $(PLUGINS_DIR)/*
exclude=${exclude_plugins_list}; \
for folder in $^ ; do \
go build -buildmode=plugin -o $${folder}/plugin.so $${folder}/*.go; \
result=$${folder%%+(/)}; \
result=$${result##*/}; \
result=$${result:-/}; \
if ! [[ $${exclude[*]} =~ "$${result}" ]]; then \
go build -buildmode=plugin --mod=mod -gcflags='all=-N -l' -o bin/plugins/$${result}.so $${folder}/*.go; \
fi \
done
riotpot-builder: \
riotpot-build \
riotpot-build-plugins
build-all: \
build \
build-plugins
ui:
@cd ui && serve -s build
Loading

0 comments on commit d3830e7

Please sign in to comment.