-
Notifications
You must be signed in to change notification settings - Fork 362
113 lines (104 loc) · 4.18 KB
/
e2e-test-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Sealer-Test-Image
on:
push:
branches: "release*"
issue_comment:
types:
- created
workflow_dispatch: { }
pull_request_target:
types: [ opened, synchronize, reopened ]
branches: "*"
paths-ignore:
- 'docs/**'
- '*.md'
- '*.yml'
- '.github'
permissions:
statuses: write
jobs:
build:
name: test
runs-on: ubuntu-latest
if: ${{ (github.event.issue.pull_request && (github.event.comment.body == '/test all' || github.event.comment.body == '/test image')) || github.event_name == 'push' || github.event_name == 'pull_request_target' }}
env:
GO111MODULE: on
steps:
- name: Get PR details
if: ${{ github.event_name == 'issue_comment' }}
uses: xt0rted/pull-request-comment-branch@v1
id: comment-branch
- name: Set commit status as pending
if: ${{ github.event_name == 'issue_comment' }}
uses: myrotvorets/set-commit-status-action@master
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: pending
- name: Github API Request
id: request
uses: octokit/[email protected]
with:
route: ${{ github.event.issue.pull_request.url }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get PR informations
id: pr_data
run: |
echo "repo_name=${{ fromJson(steps.request.outputs.data).head.repo.full_name }}" >> $GITHUB_STATE
echo "repo_clone_url=${{ fromJson(steps.request.outputs.data).head.repo.clone_url }}" >> $GITHUB_STATE
echo "repo_ssh_url=${{ fromJson(steps.request.outputs.data).head.repo.ssh_url }}" >> $GITHUB_STATE
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
path: src/github.com/sealerio/sealer
- name: Install deps
run: |
sudo su
sudo apt-get update
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
sudo mkdir /var/lib/sealer
- name: Set up Go 1.17
uses: actions/setup-go@v3
with:
go-version: 1.17
id: go
- name: Install sealer and ginkgo
shell: bash
run: |
docker run --rm -v ${PWD}:/usr/src/sealer -w /usr/src/sealer registry.cn-qingdao.aliyuncs.com/sealer-io/sealer-build:v1 make linux
export SEALER_DIR=${PWD}/_output/bin/sealer/linux_amd64
echo "$SEALER_DIR" >> $GITHUB_PATH
go install github.com/onsi/ginkgo/[email protected]
go install github.com/onsi/gomega/[email protected]
GOPATH=`go env GOPATH`
echo "$GOPATH/bin" >> $GITHUB_PATH
working-directory: src/github.com/sealerio/sealer
- name: Run sealer image test and generate coverage
shell: bash
working-directory: src/github.com/sealerio/sealer
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
REGISTRY_URL: ${{ secrets.REGISTRY_URL }}
IMAGE_NAME: ${{ secrets.IMAGE_NAME}}
if: ${{ github.event.comment.body == '/test image' || github.event.comment.body == '/test all' || github.event_name == 'push' || github.event_name == 'pull_request_target' }}
run: |
ginkgo -v -focus="sealer image" -cover -covermode=atomic -coverpkg=./... -coverprofile=/tmp/coverage-image.out -trace test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: /tmp/coverage-login.out, /tmp/coverage-image.out
flags: e2e-tests
name: codecov-umbrella
- name: Set final commit status
uses: myrotvorets/set-commit-status-action@master
if: contains(github.event.comment.body, '/test') && always()
with:
sha: ${{ steps.comment-branch.outputs.head_sha }}
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}