Skip to content

Commit 018f0d5

Browse files
authored
Merge pull request #1 from swaroopar/feature/firstVersion
initial version of agent
2 parents 82bcf7b + 67acd58 commit 018f0d5

23 files changed

+974
-0
lines changed

.github/dependabot.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
- package-ecosystem: gomod
8+
directory: /
9+
schedule:
10+
interval: daily
11+
- package-ecosystem: docker
12+
directory: /
13+
schedule:
14+
interval: daily

.github/workflows/workflows/ci.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-FileCopyrightText: Huawei Inc.
4+
#
5+
name: CI
6+
7+
# Controls when the action will run.
8+
on:
9+
# Run this workflow every time a new commit push to the repository
10+
pull_request:
11+
branches: ['main']
12+
push:
13+
branches: ['main']
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: ">=1.22"
24+
- run: go version
25+
- name: Build
26+
run: make build
27+
- name: Vet
28+
run: make test
29+
golangci:
30+
name: lint
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- uses: actions/setup-go@v5
35+
with:
36+
go-version: '1.22'
37+
cache: false
38+
- name: golangci-lint
39+
uses: golangci/golangci-lint-action@v6
40+
with:
41+
# Require: The version of golangci-lint to use.
42+
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
43+
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
44+
version: v1.54
45+
46+
# Optional: working directory, useful for monorepos
47+
# working-directory: somedir
48+
49+
# Optional: golangci-lint command line arguments.
50+
#
51+
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
52+
# The location of the configuration file can be changed by using `--config=`
53+
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0
54+
args: --timeout=10m
55+
56+
# Optional: show only new issues if it's a pull request. The default value is `false`.
57+
# only-new-issues: true
58+
59+
# Optional: if set to true, then all caching functionality will be completely disabled,
60+
# takes precedence over all other caching options.
61+
# skip-cache: true
62+
63+
# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
64+
# skip-pkg-cache: true
65+
66+
# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
67+
# skip-build-cache: true
68+
69+
# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
70+
# install-mode: "goinstall"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-FileCopyrightText: Huawei Inc.
4+
#
5+
name: license-check
6+
7+
# Run this workflow every time a new commit push to the repository
8+
on:
9+
push:
10+
branches: ['main']
11+
pull_request:
12+
branches: ['main']
13+
env:
14+
DASH_TOOL_VERSION: 1.1.0
15+
16+
jobs:
17+
third-party-license-check:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Set Up JDK 21
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: 21
24+
distribution: 'temurin'
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- name: Download Eclipse Dash Tool Jar
28+
run: wget https://repo.eclipse.org/service/local/repositories/dash-licenses-releases/content/org/eclipse/dash/org.eclipse.dash.licenses/${{ env.DASH_TOOL_VERSION }}/org.eclipse.dash.licenses-${{ env.DASH_TOOL_VERSION }}.jar
29+
- name: Run License Validation
30+
run: java -jar org.eclipse.dash.licenses-${{ env.DASH_TOOL_VERSION }}.jar go.sum
31+
# To be enabled once the initial IP check is completed by EF team.
32+
continue-on-error: true
+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
# SPDX-FileCopyrightText: Huawei Inc.
4+
#
5+
6+
name: release
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
ReleaseType:
11+
type: choice
12+
description: Select the version to released
13+
options:
14+
- Major Version
15+
- Minor Version
16+
- Patch Version
17+
18+
env:
19+
BOT_USER_NAME: eclipse-xpanse-bot
20+
BOT_EMAIL_ID: [email protected]
21+
REGISTRY: ghcr.io
22+
IMAGE_NAME: ${{ github.repository }}
23+
24+
jobs:
25+
pre-release:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: write
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
token: ${{ secrets.BOT_GITHUB_TOKEN }}
34+
- name: Set current version env variable
35+
id: version
36+
run: |
37+
echo "CurrentVersion=$(sed -n 's/^.*version.*= *"\([a-z0-9.]*\)"/\1/pg' version.go)" >> $GITHUB_OUTPUT
38+
if [ "${{github.event.inputs.ReleaseType}}" = "Major Version" ]; then
39+
echo "VersionFragment=major" >> $GITHUB_ENV
40+
elif [ "${{github.event.inputs.ReleaseType}}" = "Minor Version" ]; then
41+
echo "VersionFragment=feature" >> $GITHUB_ENV
42+
elif [ "${{github.event.inputs.ReleaseType}}" = "Patch Version" ]; then
43+
echo "VersionFragment=bug" >> $GITHUB_ENV
44+
else
45+
echo "No matching feature type found"
46+
fi
47+
- name: Set next development version environment variable
48+
id: new_version
49+
uses: christian-draeger/[email protected]
50+
with:
51+
current-version: ${{ steps.version.outputs.CurrentVersion }}
52+
version-fragment: ${{ env.VersionFragment }}
53+
- name: Update version
54+
run: |
55+
sed -i 's/\(^.*version.*= *"\)\([a-z0-9.]*\)"/\1${{ steps.new_version.outputs.next-version }}"/g' version/version.go
56+
- uses: EndBug/add-and-commit@v9
57+
with:
58+
message: Release v${{ steps.new_version.outputs.next-version }}
59+
committer_name: ${{ env.BOT_USER_NAME }}
60+
committer_email: ${{ env.BOT_EMAIL_ID }}
61+
- name: Create a GitHub tag
62+
# This action here is only target for creating a tag, but it also created a simple github release which will be rewritten by the following goreleaser job.
63+
# That may gain a little benefit in case the goreleaser job failed. Anyway, it should be replaced by some other actions which creating tags only.
64+
uses: ncipollo/release-action@v1
65+
with:
66+
tag: v${{ steps.new_version.outputs.next-version }}
67+
name: v${{ steps.new_version.outputs.next-version }}
68+
outputs:
69+
current_version: ${{ steps.version.outputs.CurrentVersion }}
70+
release_version: v${{ steps.new_version.outputs.next-version }}
71+
docker-releaser:
72+
needs: pre-release
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v4
77+
with:
78+
fetch-depth: 0
79+
ref: ${{ needs.pre-release.outputs.release_version }}
80+
- name: Set up Go
81+
uses: actions/setup-go@v5
82+
with:
83+
go-version: ">=1.21"
84+
- name: Build policy-man
85+
run: make build
86+
- name: Set up Docker Buildx
87+
uses: docker/setup-buildx-action@v3
88+
- name: Login to Github Packages
89+
uses: docker/login-action@v3
90+
with:
91+
registry: ghcr.io
92+
username: ${{ env.BOT_USER_NAME }}
93+
password: ${{ secrets.BOT_GITHUB_DOCKER_TOKEN }}
94+
- name: Extract Docker metadata
95+
id: meta
96+
uses: docker/[email protected]
97+
with:
98+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
99+
- name: Build Docker Image and Push
100+
uses: docker/[email protected]
101+
with:
102+
context: .
103+
push: true
104+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.pre-release.outputs.release_version }}
105+
labels: ${{ steps.meta.outputs.labels }}
106+
provenance: false
107+
goreleaser:
108+
runs-on: ubuntu-latest
109+
needs: pre-release
110+
permissions:
111+
contents: write
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v4
115+
with:
116+
fetch-depth: 0
117+
ref: ${{ needs.pre-release.outputs.release_version }}
118+
- name: Set up Go
119+
uses: actions/setup-go@v5
120+
with:
121+
go-version: ">=1.21"
122+
- name: Import GPG key
123+
id: import_gpg
124+
uses: crazy-max/ghaction-import-gpg@v6
125+
with:
126+
gpg_private_key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
127+
passphrase: ${{ secrets.ORG_GPG_PASSPHRASE }}
128+
- name: Run GoReleaser
129+
uses: goreleaser/goreleaser-action@v6
130+
with:
131+
version: latest
132+
args: release --rm-dist
133+
env:
134+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Default ignored files
2+
.vscode
3+
.idea
4+
*.iml
5+
xpanse-agent*

CODE_OF_CONDUCT.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Code of Conduct
2+
3+
Code of conduct for Xpanse projects are documented on our
4+
website [here](https://eclipse.dev/xpanse/docs/Contribute/code-of-conduct).

CONTRIBUTING.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Contributing
2+
3+
Contributing guidelines for Xpanse projects are documented on our
4+
website [here](https://eclipse.dev/xpanse/docs/Contribute/new-developers).

0 commit comments

Comments
 (0)