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

Workflow/saptune unittest #139

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .github/workflows/saptune-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Saptune Github Release

# Controls when the workflow will run
on:
# Triggers the workflow on pull request events but only for the master and sle-12 branch
push:
tags:
- '*'

permissions:
contents: write
packages: write

jobs:
Create_artifacts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v3
with:
go-version: '1.18'
cache: true

- name: Get current date
id: bdate
run: echo "::set-output name=bdate::$(date +'%Y-%m-%d')"

- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean --debug -ldflags "-X 'github.com/SUSE/saptune/actions.RPMVersion={{ github.ref_name }}' -X 'github.com/SUSE/saptune/actions.RPMDate={{ steps.bdate.outputs.bdate }}'"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53 changes: 30 additions & 23 deletions .github/workflows/saptune-ut.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: saptuneUnittst
name: Saptune Continuous Integration

# Controls when the workflow will run
on:
Expand All @@ -14,47 +14,54 @@ env:
CC_PREFIX: github.com/SUSE/saptune/

jobs:
saptuneUt:
Saptune_unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set ENV for codeclimate (pull_request)
- name: Pull the Container Image
run: docker pull registry.opensuse.org/home/angelabriel/st-ci-base/containers/st-ci-base:latest

- name: Run Container Image
run: docker run --name saptune-ci --privileged --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host -td -v "${{ github.workspace }}:/app" registry.opensuse.org/home/angelabriel/st-ci-base/containers/st-ci-base:latest

- name: Get Container Logs
run: docker logs saptune-ci

- name: Run saptune unit tests
run: docker exec -t saptune-ci /bin/sh -c "cd /app; ./run_saptune_ci_tst.sh;"

- name: Stop and remove Container Image
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.head_ref }}
echo "GIT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$(git rev-parse origin/${{ github.head_ref }})" >> $GITHUB_ENV
if: github.event_name == 'pull_request'
docker stop saptune-ci
docker rm saptune-ci

Code_climate_report:
needs: Saptune_unit_test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set ENV for codeclimate (push)
run: |
echo "GIT_BRANCH=${{ github.ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV
if: github.event_name == 'push'

- name: Set ENV for codeclimate (pull_request)
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.head_ref }}
echo "GIT_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$(git rev-parse origin/${{ github.head_ref }})" >> $GITHUB_ENV
if: github.event_name == 'pull_request'

- name: Download test coverage reporter
run: |
curl -L $CC_TEST_REPORTER_URL > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build

- name: Pull the Container Image
run: docker pull registry.opensuse.org/home/angelabriel/st-ci-base/containers/st-ci-base:latest

- name: Run Container Image
run: docker run --name saptune-ci --privileged --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host -td -v "${{ github.workspace }}:/app" registry.opensuse.org/home/angelabriel/st-ci-base/containers/st-ci-base:latest

- name: Get Container Logs
run: docker logs saptune-ci

- name: Run saptune unit tests
run: docker exec -t saptune-ci /bin/sh -c "cd /app; ./run_saptune_ci_tst.sh;"

- name: Code Climate report coverage
run: ./cc-test-reporter after-build --debug --prefix ${{ env.CC_PREFIX }} --exit-code $?
if: ${{ env.CC_TEST_REPORTER_ID }}

- name: Stop and remove Container Image
run: |
docker stop saptune-ci
docker rm saptune-ci