Skip to content

Commit 769fa6d

Browse files
authored
Enable GitHub Actions to build mount-helper-container debian/rpm pkgs (#155)
* enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * enable github-actions Signed-off-by: Ashima-Ashima1 <[email protected]> * rebase branch and resolve conflicts Signed-off-by: Ashima-Ashima1 <[email protected]> * minor fix Signed-off-by: Ashima-Ashima1 <[email protected]> * address review comments Signed-off-by: Ashima-Ashima1 <[email protected]> * address review comments Signed-off-by: Ashima-Ashima1 <[email protected]> * address review comments Signed-off-by: Ashima-Ashima1 <[email protected]> * address review comments Signed-off-by: Ashima-Ashima1 <[email protected]> * conditional release Signed-off-by: Ashima-Ashima1 <[email protected]> * publish tag Signed-off-by: Ashima-Ashima1 <[email protected]> * conditional release Signed-off-by: Ashima-Ashima1 <[email protected]> * conditional release Signed-off-by: Ashima-Ashima1 <[email protected]> * publish tag Signed-off-by: Ashima-Ashima1 <[email protected]> * address review comments Signed-off-by: Ashima-Ashima1 <[email protected]> * publish v0.1.0 Signed-off-by: Ashima-Ashima1 <[email protected]> --------- Signed-off-by: Ashima-Ashima1 <[email protected]>
1 parent daac745 commit 769fa6d

File tree

11 files changed

+194
-1
lines changed

11 files changed

+194
-1
lines changed

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
permissions: write-all
11+
runs-on: ubuntu-20.04
12+
13+
strategy:
14+
matrix:
15+
package_dir:
16+
- cos-csi-mounter
17+
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@v2
21+
22+
- name: Initialize CodeQL
23+
uses: github/codeql-action/init@v3
24+
with:
25+
languages: "go"
26+
27+
- name: Run Unit Tests for cos csi mounter
28+
run: sudo make ut-coverage -C ${{ matrix.package_dir }}
29+
30+
- name: Build Debian Package for cos csi mounter container
31+
run: |
32+
cd ${{ matrix.package_dir }}
33+
make packages
34+
35+
- name: Get last commit message
36+
id: check_commit
37+
run: |
38+
message=$(git log -1 --pretty=%B)
39+
message="${message//'%'/'%25'}" # Escape '%'
40+
message="${message//$'\n'/'%0A'}" # Escape newlines
41+
message="${message//$'\r'/'%0D'}" # Escape carriage returns
42+
echo "message=$message" >> "$GITHUB_OUTPUT"
43+
shell: bash
44+
45+
- name: Check Commit Message
46+
run: |
47+
echo "Commit Message: ${{ steps.check_commit.outputs.message }}"
48+
49+
- name: Latest Version (Tag and Release)
50+
id: release
51+
if: contains(steps.check_commit.outputs.message, 'publish')
52+
uses: softprops/action-gh-release@v1
53+
with:
54+
files: |
55+
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-latest.tar.gz
56+
/home/runner/work/ibm-object-csi-driver/ibm-object-csi-driver/cos-csi-mounter/cos-csi-mounter-latest.tar.gz.sha256
57+
tag_name: v0.1.0
58+
name: v0.1.0
59+
body: CSR generated with SHA1 is not supported to get certs using Metadata.
60+
61+
- name: Perform CodeQL Analysis
62+
uses: github/codeql-action/analyze@v3

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-03-27T14:07:02Z",
6+
"generated_at": "2025-04-07T07:17:35Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

cos-csi-mounter/Makefile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
NAME := cos-csi-mounter
2+
APP_VERSION := 0.0.0
3+
BUILD_DIR := $(NAME)-$(APP_VERSION)
4+
BIN_DIR := bin
5+
6+
DEBIAN_CONTROL := $(BUILD_DIR)/DEBIAN/control
7+
MAINTAINER := "IKS Storage"
8+
DEB_ARCH := all
9+
DESCRIPTION := "IBM cos-csi-mounter service"
10+
11+
INSTALL_TAR_FILE := "$(NAME)-latest.tar.gz"
12+
CHECKSUM_FILE := "$(INSTALL_TAR_FILE).sha256"
13+
14+
test:
15+
go test -v -timeout 1800s -coverprofile=cover.out ./...
16+
go tool cover -html=cover.out -o=cover.html
17+
18+
ut-coverage: test
19+
@./scripts/coverage.sh
20+
rm cover.html cover.out
21+
go mod tidy
22+
23+
build-linux:
24+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod mod -o ${BIN_DIR}/cos-csi-mounter-server -ldflags "-s -w" -a ./server/server.go
25+
26+
deb-build:
27+
deb-build: build-linux
28+
rm -rf $(BUILD_DIR)
29+
mkdir -p $(BUILD_DIR)/DEBIAN
30+
mkdir -p ${BUILD_DIR}/etc/systemd/system/ ${BUILD_DIR}/usr/local/bin/ $(BUILD_DIR)/etc/ibmcloud
31+
32+
cp install/cos-csi-mounter.service $(BUILD_DIR)/etc/systemd/system/
33+
cp install/share.conf $(BUILD_DIR)/etc/ibmcloud/
34+
cp ${BIN_DIR}/cos-csi-mounter-server $(BUILD_DIR)/usr/local/bin/
35+
cp install/postinst.sh $(BUILD_DIR)/DEBIAN/postinst
36+
cp install/prerm.sh $(BUILD_DIR)/DEBIAN/prerm
37+
38+
echo "Package: $(BUILD_DIR)" > $(DEBIAN_CONTROL)
39+
echo "Version: $(APP_VERSION)" >> $(DEBIAN_CONTROL)
40+
echo "Maintainer: $(MAINTAINER)" >> $(DEBIAN_CONTROL)
41+
echo "Architecture: $(DEB_ARCH)" >> $(DEBIAN_CONTROL)
42+
echo "Description: $(DESCRIPTION)" >> $(DEBIAN_CONTROL)
43+
# echo "Depends: mount.ibmshare-0.0.8" >> $(DEBIAN_CONTROL)
44+
45+
dpkg-deb --build $(BUILD_DIR)
46+
rm -rf $(BUILD_DIR)
47+
48+
49+
tar-package:
50+
tar-package:
51+
mkdir packages
52+
cp ${NAME}-* packages/
53+
cd packages && tar -czvf ../$(INSTALL_TAR_FILE) *
54+
sha256sum ./$(INSTALL_TAR_FILE) > $(CHECKSUM_FILE)
55+
@printf "Production - Install package created ok: $(INSTALL_TAR_FILE)\n"
56+
57+
clean:
58+
rm -rf ${BIN_DIR}
59+
rm *.deb
60+
rm -rf packages
61+
62+
packages:
63+
packages: deb-build tar-package clean

cos-csi-mounter/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module cos-csi-mounter
2+
3+
go 1.24.1
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=COS CSI mounter service
3+
DefaultDependencies=no
4+
Requires=network-online.target
5+
After=network-online.target
6+
Before=shutdown.target reboot.target halt.target
7+
8+
[Service]
9+
Type=simple
10+
ExecStart=/usr/local/bin/cos-csi-mounter-server
11+
Restart=on-failure
12+
RestartSec=10
13+
StandardOutput=journal
14+
StandardError=journal
15+
SyslogIdentifier=cos-csi-mounter
16+
17+
[Install]
18+
WantedBy=multi-user.target

cos-csi-mounter/install/postinst.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Once package is installed this script will called to enable the service
5+
systemctl enable cos-csi-mounter.service
6+
systemctl start cos-csi-mounter.service

cos-csi-mounter/install/prerm.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Or condition is added to always return success even if service is not running/available.
5+
systemctl stop cos-csi-mounter.service || true
6+
systemctl disable cos-csi-mounter.service || true

cos-csi-mounter/install/share.conf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# all - install all certificates
2+
# region list - use any combination
3+
# 7282
4+
# dal
5+
# dal_preprod
6+
# dev13
7+
# dev83
8+
# dev93
9+
# fra
10+
# lon
11+
# osa
12+
# par
13+
# sao
14+
# syd
15+
# tok
16+
# tor
17+
# wdc
18+
# wdc_preprod
19+
20+
region=all
21+
22+
certificate_duration_seconds=3600
23+
24+
metadata_retry_count=3
25+
26+
metadata_retry_interval=30

cos-csi-mounter/scripts/coverage.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
COVERAGE=$(grep "%)" <cover.html | grep -v -e "fake-" | grep -v -e "metadata.go" | sed 's/[][()><%]/ /g' | awk '{ print $4 }' | awk '{s+=$1}END{print s/NR}')
2+
3+
echo "-------------------------------------------------------------------------"
4+
echo "COVERAGE IS ${COVERAGE}%"
5+
echo "-------------------------------------------------------------------------"

cos-csi-mounter/server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package main
2+
3+
func main() {}

cos-csi-mounter/server/server_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package main

0 commit comments

Comments
 (0)