simp-test 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 748c0d1b5d2e2581bad34faadfc2f4a1ab81dd2a2453f4e8c275be82e30b8fce
4
+ data.tar.gz: 8608dc9621c6b7f2c8a30eec1017b4e7731d397ae108b99bfa7567e62ee7eeb5
5
+ SHA512:
6
+ metadata.gz: c698b62b5372acdb4ecf3baa834bc64852a72bc42b81f56ab5ead3d5c0b27d56b3d06a34e771b45b48def6079317d2abaebcefacc7a099a3950de8cf94317766
7
+ data.tar.gz: 25e8ac43d6fee80573da18d12a6189c8354f85227d7dbdafdd412b443be4e7bfade867025d2045c166f5010d78e587772555d5d7281b3aadadf58c37389847a8
@@ -0,0 +1,249 @@
1
+ # Push/Trigger a GitLab CI pipeline for the PR HEAD, **ONLY IF:**
2
+ #
3
+ # 1. The .gitlab-ci.yaml file exists and validates
4
+ # 2. The PR submitter has write access to the target repository.
5
+ #
6
+ # ==============================================================================
7
+ #
8
+ # GitHub Action Secrets variables available for this pipeline:
9
+ #
10
+ # GitHub Secret variable Type Notes
11
+ # ------------------------ -------- ----------------------------------------
12
+ # GITLAB_API_PRIVATE_TOKEN Secure Should have `api` scope
13
+ # GITLAB_API_URL Optional
14
+ #
15
+ # The secure vars will be filtered in GitHub Actions log output, and aren't
16
+ # provided to untrusted builds (i.e, triggered by PR from another repository)
17
+ #
18
+ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
19
+ # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
20
+ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!V!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21
+ #
22
+ # DO NOT MODIFY this workflow, unless you **REALLY** know what you are doing.
23
+ #
24
+ # This workflow bypasses some of the built-in protections of the
25
+ # `pull_request_target` event by explicitly checking out the PR's **HEAD**.
26
+ # Without being VERY CAREFUL, this could easily allow a malcious PR
27
+ # contributor the chance to access secrets or a GITHUB_TOKEN with write scope!!
28
+ #
29
+ # The jobs in this workflow are designed to handle this safely -- but DO NOT
30
+ # assume any alterations will also be safe.
31
+ #
32
+ # For general information, see:
33
+ #
34
+ # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target
35
+ #
36
+ # For further information, or if ANY of this seems confusing or unecessary:
37
+ #
38
+ # ASK FOR ASSISTANCE **BEFORE** ATTEMPTING TO MODIFY THIS WORKFLOW.
39
+ #
40
+ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
+ # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
42
+ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!V!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
43
+ #
44
+ # https://docs.github.com/en/actions/reference/events-that-trigger-workflows
45
+ #
46
+ ---
47
+ name: PR GLCI
48
+ on:
49
+ pull_request_target:
50
+ types: [opened, reopened, synchronize]
51
+
52
+ jobs:
53
+
54
+ # The ONLY reason we can validate the PR HEAD's content safely here is that
55
+ # we restrict ourselves to sending data elsewhere.
56
+ glci-syntax:
57
+ name: '.gitlab-ci.yml Syntax'
58
+ runs-on: ubuntu-16.04
59
+ outputs:
60
+ exists: ${{ steps.glci-file-exists.outputs.exists }}
61
+ valid: ${{ steps.validate-glci-file.outputs.valid }}
62
+ steps:
63
+ - uses: actions/checkout@v2
64
+ with:
65
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
66
+ ref: ${{ github.event.pull_request.head.ref }}
67
+ - name: 'Does GLCI file exist?'
68
+ id: glci-file-exists
69
+ run: |
70
+ if [ -f .gitlab-ci.yml ]; then
71
+ echo '.gitlab-ci.yml exists'
72
+ echo '::set-output name=exists::true'
73
+ else
74
+ echo '::error ::The ".gitlab-ci.yml" file is missing!'
75
+ echo '::set-output name=exists::false'
76
+ false
77
+ fi
78
+ - name: 'Validate GLCI file syntax'
79
+ id: validate-glci-file
80
+ if: steps.glci-file-exists.outputs.exists == 'true'
81
+ env:
82
+ GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }} # https://gitlab.com/api/v4
83
+ GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }}
84
+ run: |
85
+ GITLAB_API_URL="${GITLAB_API_URL:-https://gitlab.com/api/v4}"
86
+ CURL_CMD=(curl --http1.1 --fail --silent --show-error --header 'Content-Type: application/json' --data @-)
87
+ [ -n "$GITLAB_API_PRIVATE_TOKEN" ] && CURL_CMD+=(--header "Authorization: Bearer $GITLAB_API_PRIVATE_TOKEN")
88
+ data="$(jq --null-input --arg yaml "$(<.gitlab-ci.yml)" '.content=$yaml' )"
89
+ response="$(echo "$data" | "${CURL_CMD[@]}" "${GITLAB_API_URL}/ci/lint?include_merged_yaml=true" | jq . )"
90
+ status=$( echo "$response" | jq .status )
91
+ if [[ "$status" == '"valid"' ]]; then
92
+ echo '.gitlab-ci.yml is valid'
93
+ echo '::set-output name=valid::true'
94
+ else
95
+ echo '::set-output name=valid::false'
96
+ echo '::error::The .gitlab-ci.yml" file is invalid!'
97
+ echo "$response" | jq -r '.errors[] | . = "::error ::\(.)"'
98
+ printf "::debug ::.gitlab-ci.yml CI lint service response: %s\n" "$response"
99
+ false
100
+ fi
101
+
102
+ contributor-permissions:
103
+ name: 'PR contributor check'
104
+ runs-on: ubuntu-18.04
105
+ outputs:
106
+ permitted: ${{ steps.user-repo-permissions.outputs.permitted }}
107
+ steps:
108
+ - uses: actions/github-script@v3
109
+ id: user-repo-permissions
110
+ with:
111
+ github-token: ${{secrets.GITHUB_TOKEN}}
112
+ # See:
113
+ # - https://octokit.github.io/rest.js/
114
+ # - https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-repository-permissions-for-a-user
115
+ script: |
116
+ const project_permission = await github.request('GET /repos/{owner}/{repo}/collaborators/{username}/permission', {
117
+ headers: {
118
+ accept: 'application/vnd.github.v3+json'
119
+ },
120
+ owner: context.repo.owner,
121
+ repo: context.repo.repo,
122
+ username: context.payload.sender.login,
123
+ })
124
+ const has_write_access = perm_lvl => (perm_lvl == "admin" || perm_lvl == "write" )
125
+ const write_access_desc = perm_bool => (perm_bool ? "PERMISSION OK" : "PERMISSION DENIED" )
126
+ if( has_write_access(project_permission.data.permission )){
127
+ core.setOutput( 'permitted', 'true' )
128
+ } else {
129
+ core.setOutput( 'permitted', 'false' )
130
+ console.log(`::error ::payload user '${context.payload.sender.login}' does not have CI trigger permission for '${context.repository}; not triggering external CI'`)
131
+ }
132
+ console.log(`== payload user '${context.payload.sender.login}' CI trigger permission for '${context.repo.owner}': ${write_access_desc(has_write_access(project_permission.data.permission))}`)
133
+
134
+
135
+ trigger-when-user-has-repo-permissions:
136
+ name: 'Trigger CI [trusted users only]'
137
+ needs: [ glci-syntax, contributor-permissions ]
138
+ # This conditional provides an extra safety control, in case the workflow's
139
+ # `on` section is inadventently modified without considering the security
140
+ # implications.
141
+ #
142
+ # This job will ONLY trigger on:
143
+ #
144
+ # - [x] pull_request_target event: github.event_name == 'pull_request_target'
145
+ # AND:
146
+ # - [x] Newly-opened PRs: github.event.action == 'opened'
147
+ # - [x] Re-opened PRs: github.event.action == 'reopened'
148
+ # - [x] Commits are added to PR: github.event.action == 'synchronize'
149
+ # AND:
150
+ # - [x] .gitlab-ci.yml exists/ok: needs.glci-syntax.outputs.valid == 'true'
151
+ #
152
+ # [Not implemented] It should NEVER trigger on:
153
+ #
154
+ # - [ ] Merged PRs: github.event.pull_request.merged == 'false'
155
+ # - (the downstream GitLab mirror will take care of that)
156
+ # - Not implemented: For some reason, this conditional always fails
157
+ # - Unnecessary if on>pull_request_target>types doesn't include 'closed'
158
+ if: github.event_name == 'pull_request_target' && ( github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' ) && github.event.pull_request.merged != 'true' && needs.glci-syntax.outputs.valid == 'true' && needs.contributor-permissions.outputs.permitted == 'true'
159
+ runs-on: ubuntu-18.04
160
+ steps:
161
+ # Things we'd like to do:
162
+ # - [ ] if there's no GitLab mirror, make one
163
+ # - [ ] if there's no GitLab <-> GitHub integration, make one
164
+ # - [ ] if there's no PR check on the main GitHub branch, make one (?)
165
+ # - [x] Cancel any GLCI pipelines already pending/running for this branch
166
+ # - "created|waiting_for_resource|preparing|pending|running"
167
+ # - [x] if PR: force-push branch to GitLab
168
+ - uses: actions/checkout@v2
169
+ if: needs.contributor-permissions.outputs.permitted == 'true'
170
+ with:
171
+ fetch-depth: 0 # Need full checkout to push to gitlab mirror
172
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
173
+ ref: ${{ github.event.pull_request.head.ref }}
174
+
175
+ - name: Trigger CI when user has Repo Permissions
176
+ if: needs.contributor-permissions.outputs.permitted == 'true'
177
+ env:
178
+ GITLAB_SERVER_URL: ${{ secrets.GITLAB_SERVER_URL }} # https://gitlab.com
179
+ GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }} # https://gitlab.com/api/v4
180
+ GITLAB_ORG: ${{ github.event.organization.login }}
181
+ GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }}
182
+ GIT_BRANCH: ${{ github.event.pull_request.head.ref }}
183
+ run: |
184
+ GITLAB_SERVER_URL="${GITLAB_SERVER_URL:-https://gitlab.com}"
185
+ GITLAB_API_URL="${GITLAB_API_URL:-${GITLAB_SERVER_URL}/api/v4}"
186
+ GIT_BRANCH="${GIT_BRANCH:-GITHUB_HEAD_REF}"
187
+ GITXXB_REPO_NAME="${GITHUB_REPOSITORY/$GITHUB_REPOSITORY_OWNER\//}"
188
+ GITLAB_PROJECT_ID="${GITLAB_ORG}%2F${GITXXB_REPO_NAME}"
189
+ # --http1.0 avoids an HTTP/2 load balancing issue when run from GA
190
+ CURL_CMD=(curl --http1.0 --fail --silent --show-error \
191
+ --header "Authorization: Bearer $GITLAB_API_PRIVATE_TOKEN" \
192
+ --header "Content-Type: application/json" \
193
+ --header "Accept: application/json" \
194
+ )
195
+
196
+ # Cancel any active/pending GitLab CI pipelines for the same project+branch
197
+ active_pipeline_ids=()
198
+ for pipe_status in created waiting_for_resource preparing pending running; do
199
+ echo " ---- checking for CI pipelines with status '$pipe_status' for project '$GITLAB_PROJECT_ID', branch '$GIT_BRANCH'"
200
+ url="${GITLAB_API_URL}/projects/${GITLAB_PROJECT_ID}/pipelines?ref=${GIT_BRANCH}&status=${pipe_status}"
201
+ active_pipelines="$("${CURL_CMD[@]}" "$url" | jq -r '.[] | .id , .web_url')"
202
+ active_pipeline_ids+=($(echo "$active_pipelines" | grep -E '^[0-9]*$'))
203
+ printf "$active_pipelines\n\n"
204
+ done
205
+ if [ "${#active_pipeline_ids[@]}" -gt 0 ]; then
206
+ printf "\nFound %s active pipeline ids:\n" "${#active_pipeline_ids[@]}"
207
+ echo "${active_pipeline_ids[@]}"
208
+ for pipe_id in "${active_pipeline_ids[@]}"; do
209
+ printf "\n ------ Cancelling pipeline ID %s...\n" "$pipe_id"
210
+ "${CURL_CMD[@]}" --request POST "${GITLAB_API_URL}/projects/${GITLAB_PROJECT_ID}/pipelines/${pipe_id}/cancel"
211
+ done
212
+ else
213
+ echo No active pipelines found
214
+ fi
215
+
216
+ echo "== Pushing $GIT_BRANCH to gitlab"
217
+ git remote add gitlab "https://oauth2:${GITLAB_API_PRIVATE_TOKEN}@${GITLAB_SERVER_URL#*://}/${GITLAB_ORG}/${GITXXB_REPO_NAME}.git"
218
+ #git branch "$GIT_BRANCH" HEAD
219
+ git log --color --graph --abbrev-commit -5 \
220
+ --pretty=format:'%C(red)%h%C(reset) -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset'
221
+ git push gitlab ":${GIT_BRANCH}" -f || : # attempt to un-weird GLCI's `changed` tracking
222
+ git push gitlab "${GIT_BRANCH}" -f
223
+ echo "Pushed branch '${GIT_BRANCH}' to gitlab"
224
+ echo " A new pipeline should be at: https://${GITLAB_SERVER_URL#*://}/${GITLAB_ORG}/${GITXXB_REPO_NAME}/-/pipelines/"
225
+
226
+ - name: When user does NOT have Repo Permissions
227
+ if: needs.contributor-permissions.outputs.permitted == 'false'
228
+ continue-on-error: true
229
+ run: |
230
+ echo "Ending gracefully; Contributor $GITHUB_ACTOR does not have permission to trigger CI"
231
+ false
232
+
233
+ ### examine_contexts:
234
+ ### name: 'Examine Context contents'
235
+ ### if: always()
236
+ ### runs-on: ubuntu-16.04
237
+ ### needs: [ glci-syntax, contributor-permissions ]
238
+ ### steps:
239
+ ### - name: Dump contexts
240
+ ### env:
241
+ ### GITHUB_CONTEXT: ${{ toJson(github) }}
242
+ ### run: echo "$GITHUB_CONTEXT"
243
+ ### - name: Dump needs context
244
+ ### env:
245
+ ### ENV_CONTEXT: ${{ toJson(needs) }}
246
+ ### run: echo "$ENV_CONTEXT"
247
+ ### - name: Dump env vars
248
+ ### run: env | sort
249
+
@@ -0,0 +1,97 @@
1
+ # When a PR is closed, clean up any associated GitLab CI pipelines & branch
2
+ #
3
+ # * Cancels all GLCI pipelines associated with the PR HEAD ref (branch)
4
+ # * Removes the PR HEAD branch from the corresponding gitlab.com/org/ project
5
+ #
6
+ # ==============================================================================
7
+ #
8
+ # GitHub Action Secrets variables available for this pipeline:
9
+ #
10
+ # GitHub Secret variable Type Notes
11
+ # ------------------------ -------- ----------------------------------------
12
+ # GITLAB_API_PRIVATE_TOKEN Secure Should have `api` scope
13
+ # GITLAB_API_URL Optional
14
+ #
15
+ # The secure vars will be filtered in GitHub Actions log output, and aren't
16
+ # provided to untrusted builds (i.e, triggered by PR from another repository)
17
+ #
18
+ # ------------------------------------------------------------------------------
19
+ #
20
+ # https://docs.github.com/en/actions/reference/events-that-trigger-workflows
21
+ #
22
+ ---
23
+ name: PR GLCI Cleanup
24
+ on:
25
+ pull_request_target:
26
+ types: [closed]
27
+
28
+ jobs:
29
+ cleanup-glci-branch:
30
+ name: 'Clean up GLCI'
31
+ # This conditional provides an extra safety control, in case the workflow's
32
+ # `on` section is inadventently modified without considering the security
33
+ # implications.
34
+ if: github.event_name == 'pull_request_target' && github.event.action == 'closed'
35
+ runs-on: ubuntu-18.04
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+ with:
39
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
40
+ ref: ${{ github.event.pull_request.head.ref }}
41
+ - name: Trigger CI when user has Repo Permissions
42
+ env:
43
+ GITLAB_SERVER_URL: ${{ secrets.GITLAB_SERVER_URL }} # https://gitlab.com
44
+ GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }} # https://gitlab.com/api/v4
45
+ GITLAB_ORG: ${{ github.event.organization.login }}
46
+ GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }}
47
+ GIT_BRANCH: ${{ github.event.pull_request.head.ref }}
48
+ run: |
49
+ GITLAB_SERVER_URL="${GITLAB_SERVER_URL:-https://gitlab.com}"
50
+ GITLAB_API_URL="${GITLAB_API_URL:-${GITLAB_SERVER_URL}/api/v4}"
51
+ GIT_BRANCH="${GIT_BRANCH:-GITHUB_HEAD_REF}"
52
+ GITXXB_REPO_NAME="${GITHUB_REPOSITORY/$GITHUB_REPOSITORY_OWNER\//}"
53
+ GITLAB_PROJECT_ID="${GITLAB_ORG}%2F${GITXXB_REPO_NAME}"
54
+ # --http1.0 avoids an HTTP/2 load balancing issue when run from GA
55
+ CURL_CMD=(curl --http1.0 --fail --silent --show-error \
56
+ --header "Authorization: Bearer $GITLAB_API_PRIVATE_TOKEN" \
57
+ --header "Content-Type: application/json" \
58
+ --header "Accept: application/json" \
59
+ )
60
+
61
+ # Cancel any active/pending GitLab CI pipelines for the same project+branch
62
+ active_pipeline_ids=()
63
+ for pipe_status in created waiting_for_resource preparing pending running; do
64
+ echo " ---- checking for CI pipelines with status '$pipe_status' for project '$GITLAB_PROJECT_ID', branch '$GIT_BRANCH'"
65
+ url="${GITLAB_API_URL}/projects/${GITLAB_PROJECT_ID}/pipelines?ref=${GIT_BRANCH}&status=${pipe_status}"
66
+ active_pipelines="$("${CURL_CMD[@]}" "$url" | jq -r '.[] | .id , .web_url')"
67
+ active_pipeline_ids+=($(echo "$active_pipelines" | grep -E '^[0-9]*$'))
68
+ printf "$active_pipelines\n\n"
69
+ done
70
+ if [ "${#active_pipeline_ids[@]}" -gt 0 ]; then
71
+ printf "\nFound %s active pipeline ids:\n" "${#active_pipeline_ids[@]}"
72
+ echo "${active_pipeline_ids[@]}"
73
+ for pipe_id in "${active_pipeline_ids[@]}"; do
74
+ printf "\n ------ Cancelling pipeline ID %s...\n" "$pipe_id"
75
+ "${CURL_CMD[@]}" --request POST "${GITLAB_API_URL}/projects/${GITLAB_PROJECT_ID}/pipelines/${pipe_id}/cancel"
76
+ done
77
+ else
78
+ echo No active pipelines found
79
+ fi
80
+
81
+ echo "== Removing $GIT_BRANCH from gitlab"
82
+ git remote add gitlab "https://oauth2:${GITLAB_API_PRIVATE_TOKEN}@${GITLAB_SERVER_URL#*://}/${GITLAB_ORG}/${GITXXB_REPO_NAME}.git"
83
+ git push gitlab ":${GIT_BRANCH}" -f || : # attempt to un-weird GLCI's `changed` tracking
84
+
85
+ ### examine_contexts:
86
+ ### name: 'Examine Context contents'
87
+ ### if: always()
88
+ ### runs-on: ubuntu-16.04
89
+ ### steps:
90
+ ### - name: Dump contexts
91
+ ### env:
92
+ ### GITHUB_CONTEXT: ${{ toJson(github) }}
93
+ ### run: echo "$GITHUB_CONTEXT"
94
+ ### run: echo "$ENV_CONTEXT"
95
+ ### - name: Dump env vars
96
+ ### run: env | sort
97
+
@@ -0,0 +1,206 @@
1
+ # Manually trigger GLCI pipelines for a PR
2
+ # ==============================================================================
3
+ #
4
+ # This pipeline uses the following GitHub Action Secrets:
5
+ #
6
+ # GitHub Secret variable Type Notes
7
+ # ------------------------ -------- ----------------------------------------
8
+ # GITLAB_API_PRIVATE_TOKEN Required GitLab token (should have `api` scope)
9
+ # NO_SCOPE_GITHUB_TOKEN Required GitHub token (should have no scopes)
10
+ # GITLAB_SERVER_URL Optional Specify a GL server other than gitlab.com
11
+ # The secure vars will be filtered in GitHub Actions log output, and aren't
12
+ # provided to untrusted builds (i.e, triggered by PR from another repository)
13
+ #
14
+ # ------------------------------------------------------------------------------
15
+ #
16
+ # NOTES:
17
+ # It is necessary to provide NO_SCOPE_GITHUB_TOKEN because $secrets.GITHUB_AUTO
18
+ # is NOT provide to manually-triggered (`workflow_dispatch`) events, in order
19
+ # to prevent recursive triggers between workflows
20
+ #
21
+ # Reference:
22
+ #
23
+ # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
24
+ ---
25
+ name: 'Manual: PR GLCI'
26
+
27
+ on:
28
+ workflow_dispatch:
29
+ inputs:
30
+ pr_number:
31
+ description: "PR number to trigger GLCI"
32
+ required: true
33
+
34
+ jobs:
35
+ glci-syntax:
36
+ name: '.gitlab-ci.yml Syntax'
37
+ runs-on: ubuntu-16.04
38
+ outputs:
39
+ exists: ${{ steps.glci-file-exists.outputs.exists }}
40
+ valid: ${{ steps.validate-glci-file.outputs.valid }}
41
+ pr_head_ref: ${{ steps.get-pr.outputs.pr_head_ref }}
42
+ pr_head_sha: ${{ steps.get-pr.outputs.pr_head_sha }}
43
+ pr_head_label: ${{ steps.get-pr.outputs.pr_head_label }}
44
+ pr_head_full_name: ${{ steps.get-pr.outputs.pr_full_name }}
45
+ steps:
46
+ - uses: actions/github-script@v3
47
+ id: get-pr
48
+ with:
49
+ github-token: ${{secrets.NO_SCOPE_GITHUB_TOKEN}}
50
+ # See:
51
+ # - https://octokit.github.io/rest.js/
52
+ script: |
53
+ console.log(`== pr number: ${context.payload.inputs.pr_number}`)
54
+ const pr = await github.request('get /repos/{owner}/{repo}/pulls/{pull_number}', {
55
+ headers: {
56
+ accept: 'application/vnd.github.v3+json'
57
+ },
58
+ owner: context.repo.owner,
59
+ repo: context.repo.repo,
60
+ pull_number: context.payload.inputs.pr_number
61
+ });
62
+
63
+ console.log("\n\n== pr\n");
64
+ console.log(pr);
65
+ console.log("\n\n== pr.data.head\n");
66
+ console.log(pr.data.head);
67
+ console.log(pr.status);
68
+
69
+ // PR must have been returned
70
+ if ( pr.status != 200 ) {
71
+ //#console.log(`::error ::Error looking up PR \#${context.payload.inputs.pr_number}: HTTP Response ${pr.status}`)
72
+ return(false)
73
+ }
74
+
75
+ // TODO: should either of these conditions really prevent a GLCI trigger?
76
+ if ( pr.data.state != 'open' ) {
77
+ console.log(`::error ::PR# ${context.payload.inputs.pr_number} is not open`)
78
+ }
79
+ if ( pr.data.merged ) {
80
+ console.log(`::error ::PR# ${context.payload.inputs.pr_number} is already merged`)
81
+ }
82
+ core.setOutput( 'pr_head_sha', pr.data.head.sha )
83
+ core.setOutput( 'pr_head_ref', pr.data.head.ref )
84
+ core.setOutput( 'pr_head_label', pr.data.head.label )
85
+ core.setOutput( 'pr_head_full_name', pr.data.head.full_name )
86
+ - uses: actions/checkout@v2
87
+ with:
88
+ repository: ${{ steps.get-pr.outputs.pr_head_full_name }}
89
+ ref: ${{ steps.get-pr.outputs.pr_head_sha }}
90
+ token: ${{secrets.NO_SCOPE_GITHUB_TOKEN}}
91
+ clean: true
92
+ - name: 'Does GLCI file exist?'
93
+ id: glci-file-exists
94
+ run: |
95
+ if [ -f .gitlab-ci.yml ]; then
96
+ echo '.gitlab-ci.yml exists'
97
+ echo '::set-output name=exists::true'
98
+ else
99
+ echo '::error ::The ".gitlab-ci.yml" file is missing!'
100
+ echo '::set-output name=exists::false'
101
+ false
102
+ fi
103
+ - name: 'Validate GLCI file syntax'
104
+ id: validate-glci-file
105
+ env:
106
+ GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }} # https://gitlab.com/api/v4
107
+ GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }}
108
+ run: |
109
+ GITLAB_API_URL="${GITLAB_API_URL:-https://gitlab.com/api/v4}"
110
+ CURL_CMD=(curl --http1.1 --fail --silent --show-error --header 'Content-Type: application/json' --data @-)
111
+ [ -n "$GITLAB_API_PRIVATE_TOKEN" ] && CURL_CMD+=(--header "Authorization: Bearer $GITLAB_API_PRIVATE_TOKEN")
112
+ data="$(jq --null-input --arg yaml "$(<.gitlab-ci.yml)" '.content=$yaml' )"
113
+ response="$(echo "$data" | "${CURL_CMD[@]}" "${GITLAB_API_URL}/ci/lint?include_merged_yaml=true" | jq . )"
114
+ status=$( echo "$response" | jq .status )
115
+ if [[ "$status" == '"valid"' ]]; then
116
+ echo '.gitlab-ci.yml is valid'
117
+ echo '::set-output name=valid::true'
118
+ else
119
+ echo '::set-output name=valid::false'
120
+ echo '::error::The .gitlab-ci.yml" file is invalid!'
121
+ echo "$response" | jq -r '.errors[] | . = "::error ::\(.)"'
122
+ printf "::debug ::.gitlab-ci.yml CI lint service response: %s\n" "$response"
123
+ false
124
+ fi
125
+
126
+ trigger-when-user-has-repo-permissions:
127
+ name: 'Trigger CI'
128
+ needs: [ glci-syntax ]
129
+ runs-on: ubuntu-16.04
130
+ steps:
131
+ - uses: actions/checkout@v2
132
+ with:
133
+ repository: ${{ needs.glci-syntax.outputs.pr_head_full_name }}
134
+ ref: ${{ needs.glci-syntax.outputs.pr_head_sha }}
135
+ token: ${{secrets.NO_SCOPE_GITHUB_TOKEN}}
136
+ fetch-depth: 0 # Need full checkout to push to gitlab mirror
137
+ clean: true
138
+ - name: Trigger CI
139
+ env:
140
+ GITLAB_SERVER_URL: ${{ secrets.GITLAB_SERVER_URL }} # https://gitlab.com
141
+ GITLAB_API_URL: ${{ secrets.GITLAB_API_URL }} # https://gitlab.com/api/v4
142
+ GITLAB_ORG: ${{ github.event.organization.login }}
143
+ GITLAB_API_PRIVATE_TOKEN: ${{ secrets.GITLAB_API_PRIVATE_TOKEN }}
144
+ GIT_BRANCH: ${{ needs.glci-syntax.outputs.pr_head_ref }}
145
+ run: |
146
+ GITLAB_SERVER_URL="${GITLAB_SERVER_URL:-https://gitlab.com}"
147
+ GITLAB_API_URL="${GITLAB_API_URL:-${GITLAB_SERVER_URL}/api/v4}"
148
+ GITXXB_REPO_NAME="${GITHUB_REPOSITORY/$GITHUB_REPOSITORY_OWNER\//}"
149
+ GITLAB_PROJECT_ID="${GITLAB_ORG}%2F${GITXXB_REPO_NAME}"
150
+ # --http1.0 avoids an HTTP/2 load balancing issue when run from GA
151
+ CURL_CMD=(curl --http1.0 --fail --silent --show-error \
152
+ --header "Authorization: Bearer $GITLAB_API_PRIVATE_TOKEN" \
153
+ --header "Content-Type: application/json" \
154
+ --header "Accept: application/json" \
155
+ )
156
+
157
+ # Cancel any active/pending GitLab CI pipelines for the same project+branch
158
+ active_pipeline_ids=()
159
+ for pipe_status in created waiting_for_resource preparing pending running; do
160
+ echo " ---- checking for CI pipelines with status '$pipe_status' for project '$GITLAB_PROJECT_ID', branch '$GIT_BRANCH'"
161
+ url="${GITLAB_API_URL}/projects/${GITLAB_PROJECT_ID}/pipelines?ref=${GIT_BRANCH}&status=${pipe_status}"
162
+ active_pipelines="$("${CURL_CMD[@]}" "$url" | jq -r '.[] | .id , .web_url')"
163
+ active_pipeline_ids+=($(echo "$active_pipelines" | grep -E '^[0-9]*$'))
164
+ printf "$active_pipelines\n\n"
165
+ done
166
+ if [ "${#active_pipeline_ids[@]}" -gt 0 ]; then
167
+ printf "\nFound %s active pipeline ids:\n" "${#active_pipeline_ids[@]}"
168
+ echo "${active_pipeline_ids[@]}"
169
+ for pipe_id in "${active_pipeline_ids[@]}"; do
170
+ printf "\n ------ Cancelling pipeline ID %s...\n" "$pipe_id"
171
+ "${CURL_CMD[@]}" --request POST "${GITLAB_API_URL}/projects/${GITLAB_PROJECT_ID}/pipelines/${pipe_id}/cancel"
172
+ done
173
+ else
174
+ echo No active pipelines found
175
+ fi
176
+
177
+ # Should we protect against pushing default branches?
178
+ echo "== Pushing '$GIT_BRANCH' to gitlab"
179
+ git remote add gitlab "https://oauth2:${GITLAB_API_PRIVATE_TOKEN}@${GITLAB_SERVER_URL#*://}/${GITLAB_ORG}/${GITXXB_REPO_NAME}.git"
180
+ git branch "$GIT_BRANCH" HEAD || :
181
+ git branch -av
182
+ git log --color --graph --abbrev-commit -5 \
183
+ --pretty=format:'%C(red)%h%C(reset) -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset'
184
+ git push gitlab ":${GIT_BRANCH}" -f || : # attempt to un-weird GLCI's `changed` tracking
185
+ echo "== git push --verbose gitlab ${GIT_BRANCH}"
186
+ git push --verbose gitlab "${GIT_BRANCH}"
187
+ echo "Pushed branch '${GIT_BRANCH}' to gitlab"
188
+ echo " A new pipeline should be at: https://${GITLAB_SERVER_URL#*://}/${GITLAB_ORG}/${GITXXB_REPO_NAME}/-/pipelines/"
189
+
190
+ ### examine_contexts:
191
+ ### needs: [ glci-syntax ]
192
+ ### name: 'Examine Context contents'
193
+ ### if: always()
194
+ ### runs-on: ubuntu-16.04
195
+ ### steps:
196
+ ### - name: Dump contexts
197
+ ### env:
198
+ ### GITHUB_CONTEXT: ${{ toJson(github) }}
199
+ ### run: echo "$GITHUB_CONTEXT"
200
+ ### - name: Dump 'needs' context
201
+ ### env:
202
+ ### ENV_CONTEXT: ${{ toJson(needs) }}
203
+ ### run: echo "$ENV_CONTEXT"
204
+ ### - name: Dump env vars
205
+ ### run: env | sort
206
+
@@ -0,0 +1,94 @@
1
+ # The testing matrix considers ruby/puppet versions supported by SIMP and PE:
2
+ # ------------------------------------------------------------------------------
3
+ # Release Puppet Ruby EOL
4
+ # SIMP 6.4 5.5 2.40 TBD
5
+ # PE 2018.1 5.5 2.40 2021-01 (LTS overlap)
6
+ # PE 2019.8 6.18 2.5 2022-12 (LTS)
7
+ #
8
+ # https://puppet.com/docs/pe/2018.1/component_versions_in_recent_pe_releases.html
9
+ # https://puppet.com/misc/puppet-enterprise-lifecycle
10
+ # https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html
11
+ # ==============================================================================
12
+ #
13
+ # https://docs.github.com/en/actions/reference/events-that-trigger-workflows
14
+ #
15
+
16
+ name: PR Tests
17
+ on:
18
+ pull_request:
19
+ types: [opened, reopened, synchronize]
20
+
21
+ env:
22
+ PUPPET_VERSION: '~> 6'
23
+
24
+ jobs:
25
+ ruby-style:
26
+ if: false # TODO Modules will need: rubocop in Gemfile, .rubocop.yml
27
+ name: 'Ruby Style (experimental)'
28
+ runs-on: ubuntu-18.04
29
+ continue-on-error: true
30
+ steps:
31
+ - uses: actions/checkout@v2
32
+ - name: "Install Ruby ${{matrix.puppet.ruby_version}}"
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: 2.5
36
+ bundler-cache: true
37
+ - run: |
38
+ bundle show
39
+ bundle exec rake rubocop
40
+
41
+ # releng-checks:
42
+ # name: 'RELENG checks'
43
+ # runs-on: ubuntu-18.04
44
+ # steps:
45
+ # - uses: actions/checkout@v2
46
+ # - name: 'Install Ruby ${{matrix.puppet.ruby_version}}'
47
+ # uses: ruby/setup-ruby@v1
48
+ # with:
49
+ # ruby-version: 2.5
50
+ # bundler-cache: true
51
+ # - name: 'Tags and changelogs'
52
+ # run: |
53
+ # bundle exec rake pkg:check_version
54
+ # bundle exec rake pkg:compare_latest_tag
55
+ # bundle exec rake pkg:create_tag_changelog
56
+ # - name: 'Test-build the Puppet module'
57
+ # run: 'bundle exec pdk build --force'
58
+
59
+ spec-tests:
60
+ name: 'Spec tests'
61
+ runs-on: ubuntu-18.04
62
+ strategy:
63
+ matrix:
64
+ puppet:
65
+ - label: 'Puppet 6.18 [SIMP 6.5/PE 2019.8]'
66
+ puppet_version: '~> 6.18.0'
67
+ ruby_version: '2.5'
68
+ - label: 'Puppet 5.5 [SIMP 6.4/PE 2018.1]'
69
+ puppet_version: '~> 5.5.22'
70
+ ruby_version: '2.4'
71
+ - label: 'Puppet 7.x'
72
+ puppet_version: '~> 7.0'
73
+ ruby_version: '2.7'
74
+ env:
75
+ PUPPET_VERSION: '${{matrix.puppet.puppet_version}}'
76
+ steps:
77
+ - uses: actions/checkout@v2
78
+ - name: 'Install Ruby ${{matrix.puppet.ruby_version}}'
79
+ uses: ruby/setup-ruby@v1
80
+ with:
81
+ ruby-version: ${{matrix.puppet.ruby_version}}
82
+ bundler-cache: true
83
+ - run: 'command -v rpm || if command -v apt-get; then apt-get update; apt-get install -y rpm; fi ||:'
84
+ - run: 'bundle exec rake spec'
85
+
86
+ dump_contexts:
87
+ name: 'Examine Context contents'
88
+ runs-on: ubuntu-16.04
89
+ steps:
90
+ - name: Dump contexts
91
+ env:
92
+ GITHUB_CONTEXT: ${{ toJson(github) }}
93
+ run: echo "$GITHUB_CONTEXT"
94
+
@@ -0,0 +1,154 @@
1
+ # Build & Deploy RubyGem & GitHub release when a SemVer tag is pushed
2
+ # ------------------------------------------------------------------------------
3
+ #
4
+ # NOTICE: **This file is maintained with puppetsync**
5
+ #
6
+ # This file is updated automatically as part of an asset baseline.
7
+ #
8
+ # The next baseline sync will overwrite any local changes to this file!
9
+ #
10
+ # ==============================================================================
11
+ #
12
+ # This pipeline uses the following GitHub Action Secrets:
13
+ #
14
+ # GitHub Secret variable Type Notes
15
+ # ------------------------ -------- ----------------------------------------
16
+ # RUBYGEMS_API_KEY Required
17
+ #
18
+ # ------------------------------------------------------------------------------
19
+ #
20
+ # NOTES:
21
+ #
22
+ # * The CHANGLOG text is altered to remove RPM-style date headers, which don't
23
+ # render well as markdown on the GitHub release pages
24
+ ---
25
+ name: 'Tag: Release to GitHub & rubygems.org'
26
+
27
+ on:
28
+ push:
29
+ tags:
30
+ - '[0-9]+\.[0-9]+\.[0-9]+'
31
+
32
+ env:
33
+ PUPPET_VERSION: '~> 6'
34
+ LOCAL_WORKFLOW_CONFIG_FILE: .github/workflows.local.json
35
+
36
+ jobs:
37
+ releng-checks:
38
+ name: "RELENG checks"
39
+ runs-on: ubuntu-18.04
40
+ outputs:
41
+ build_command: ${{ steps.commands.outputs.build_command }}
42
+ release_command: ${{ steps.commands.outputs.release_command }}
43
+ steps:
44
+ - name: "Assert '${{ github.ref }}' is a tag"
45
+ run: '[[ "$GITHUB_REF" =~ ^refs/tags/ ]] || { echo "::error ::GITHUB_REF is not a tag: ${GITHUB_REF}"; exit 1 ; }'
46
+ - uses: actions/checkout@v2
47
+ with:
48
+ ref: ${{ github.ref }}
49
+ clean: true
50
+ - name: Determing build and release commands
51
+ id: commands
52
+ run: |
53
+ # By default, these are the standard tasks from "bundler/gem_tasks"
54
+ # To override them in the LOCAL_WORKFLOW_CONFIG_FILE
55
+ GEM_BUILD_COMMAND='bundle exec rake build'
56
+ GEM_RELEASE_COMMAND='gem push pkg/*.gem'
57
+ if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
58
+ grep -w '"gem_build_command"' &> /dev/null; then
59
+ GEM_BUILD_COMMAND="$(jq .gem_build_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
60
+ fi
61
+ if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
62
+ grep -w '"gem_release_command"' &> /dev/null; then
63
+ GEM_RELEASE_COMMAND="$(jq .gem_release_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
64
+ fi
65
+ echo "::set-output name=build_command::${GEM_BUILD_COMMAND}"
66
+ echo "::set-output name=release_command::${GEM_RELEASE_COMMAND}"
67
+ echo "+set-output name=build_command::${GEM_BUILD_COMMAND}"
68
+ echo "+set-output name=release_command::${GEM_RELEASE_COMMAND}"
69
+ - uses: ruby/setup-ruby@v1
70
+ with:
71
+ ruby-version: 2.5
72
+ bundler-cache: true
73
+ - name: Test build the package
74
+ run: "${{ steps.commands.outputs.build_command }}"
75
+
76
+ create-github-release:
77
+ name: Deploy GitHub Release
78
+ needs: [ releng-checks ]
79
+ runs-on: ubuntu-18.04
80
+ steps:
81
+ - name: Checkout code
82
+ uses: actions/checkout@v2
83
+ with:
84
+ ref: ${{ github.ref }}
85
+ clean: true
86
+ fetch-depth: 0
87
+ - name: Get tag & annotation info (${{github.ref}})
88
+ id: tag-check
89
+ run: |
90
+ tag="${GITHUB_REF/refs\/tags\//}"
91
+ annotation="$(git for-each-ref "$GITHUB_REF" --format='%(contents)' --count=1)"
92
+ annotation_title="$(echo "$annotation" | head -1)"
93
+
94
+ echo "::set-output name=tag::${tag}"
95
+ echo "::set-output name=annotation_title::${annotation_title}"
96
+
97
+ # Prepare annotation body as a file for the next step
98
+ #
99
+ # * The GitHub Release render the text in this file as markdown
100
+ # * The file is needed because :set-output only supports single lines
101
+ # * The `perl -pe` removes RPM-style date headers from the CHANGELOG,
102
+ # because they don't render well as markdown on the Release page
103
+ #
104
+ echo "$annotation" | tail -n +2 | \
105
+ perl -pe 'BEGIN{undef $/;} s/\n\* (Mon|Tue|Wed|Thu|Fri|Sat|Sun) .*?\n//smg;' > /tmp/annotation.body
106
+
107
+ - name: Create Release
108
+ uses: actions/create-release@v1
109
+ id: create_release
110
+ env:
111
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112
+ with:
113
+ tag_name: ${{ github.ref }}
114
+ release_name: ${{ steps.tag-check.outputs.annotation_title }}
115
+ body_path: /tmp/annotation.body
116
+ draft: false
117
+ prerelease: false
118
+
119
+ deploy-rubygem:
120
+ name: Deploy RubyGem Release
121
+ needs: [ releng-checks ]
122
+ runs-on: ubuntu-18.04
123
+ env:
124
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
125
+ BUILD_COMMAND: ${{ needs.releng-checks.outputs.build_command }}
126
+ RELEASE_COMMAND: ${{ needs.releng-checks.outputs.release_command }}
127
+ steps:
128
+ - name: Checkout code
129
+ uses: actions/checkout@v2
130
+ with:
131
+ ref: ${{ github.ref }}
132
+ clean: true
133
+ - uses: ruby/setup-ruby@v1
134
+ with:
135
+ ruby-version: 2.5
136
+ bundler-cache: true
137
+ - name: Build RubyGem
138
+ run: '$BUILD_COMMAND'
139
+
140
+ - name: Release RubyGem
141
+ run: |
142
+ echo "Setting up gem credentials..."
143
+ mkdir -p ~/.gem
144
+
145
+ cat << EOF > ~/.gem/credentials
146
+ ---
147
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
148
+ EOF
149
+ chmod 0600 ~/.gem/credentials
150
+
151
+ chmod -R go=u-w .
152
+
153
+ echo "Running '$RELEASE_COMMAND'..."
154
+ $RELEASE_COMMAND
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
@@ -0,0 +1,28 @@
1
+ ---
2
+ # Official language image. Look for the different tagged releases at:
3
+ # https://hub.docker.com/r/library/ruby/tags/
4
+ image: "ruby:2.5"
5
+
6
+ # Cache gems in between builds
7
+ cache:
8
+ paths:
9
+ - .vendor/ruby
10
+
11
+ # This is a basic example for a gem or script which doesn't use
12
+ # services such as redis or postgres
13
+ before_script:
14
+ - ruby -v # Print out ruby version for debugging
15
+ - bundle install -j $(nproc) --path .vendor # Install dependencies into ./vendor/ruby
16
+
17
+ # Optional - Delete if not using `rubocop`
18
+ rubocop:
19
+ tags:
20
+ - docker
21
+ script:
22
+ - bundle exec rubocop
23
+
24
+ rspec:
25
+ tags:
26
+ - docker
27
+ script:
28
+ - bundle exec rspec spec
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in simp-test.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 12.0'
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop'
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ rubygem-simp-test - An inert gem to test CI
2
+
3
+ --
4
+
5
+ Per Section 105 of the Copyright Act of 1976, these works are not entitled to
6
+ domestic copyright protection under US Federal law.
7
+
8
+ The US Government retains the right to pursue copyright protections outside of
9
+ the United States.
10
+
11
+ The United States Government has unlimited rights in this software and all
12
+ derivatives thereof, pursuant to the contracts under which it was developed and
13
+ the License under which it falls.
14
+
15
+ ---
16
+
17
+ Licensed under the Apache License, Version 2.0 (the "License");
18
+ you may not use this file except in compliance with the License.
19
+ You may obtain a copy of the License at
20
+
21
+ http://www.apache.org/licenses/LICENSE-2.0
22
+
23
+ Unless required by applicable law or agreed to in writing, software
24
+ distributed under the License is distributed on an "AS IS" BASIS,
25
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ See the License for the specific language governing permissions and
27
+ limitations under the License.
@@ -0,0 +1,34 @@
1
+ # Simp::Test
2
+
3
+ This gem does nothing; it is used to test CI
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'simp-test'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install simp-test
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/simp-test.
34
+
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'simp/test'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simp/test/version'
4
+
5
+ module Simp
6
+ module Test
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simp
4
+ module Test
5
+ VERSION = '0.2.0'
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/simp/test/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'simp-test'
7
+ spec.version = Simp::Test::VERSION
8
+ spec.authors = ['SIMP Team']
9
+ spec.email = ['info@simp-project.com']
10
+
11
+ spec.summary = 'test gem for CI'
12
+ spec.homepage = 'https://github.com/simp/rubygem-simp-test'
13
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
14
+
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+ spec.metadata['source_code_uri'] = 'https://github.com/simp/rubygem-simp-test'
17
+ spec.metadata['changelog_uri'] = 'https://github.com/simp/rubygem-simp-test/blob/master/CHANGELOG.md'
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+ spec.bindir = 'exe'
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ['lib']
27
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simp-test
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - SIMP Team
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-01-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - info@simp-project.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".github/workflows/pr_glci.yml"
21
+ - ".github/workflows/pr_glci_cleanup.yml"
22
+ - ".github/workflows/pr_glci_manual.yml"
23
+ - ".github/workflows/pr_tests.yml"
24
+ - ".github/workflows/tag_deploy_rubygem.yml"
25
+ - ".gitignore"
26
+ - ".gitlab-ci.yml"
27
+ - ".rspec"
28
+ - Gemfile
29
+ - LICENSE
30
+ - README.md
31
+ - Rakefile
32
+ - bin/console
33
+ - bin/setup
34
+ - lib/simp/test.rb
35
+ - lib/simp/test/version.rb
36
+ - simp-test.gemspec
37
+ homepage: https://github.com/simp/rubygem-simp-test
38
+ licenses: []
39
+ metadata:
40
+ homepage_uri: https://github.com/simp/rubygem-simp-test
41
+ source_code_uri: https://github.com/simp/rubygem-simp-test
42
+ changelog_uri: https://github.com/simp/rubygem-simp-test/blob/master/CHANGELOG.md
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: 2.3.0
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.7.6.2
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: test gem for CI
63
+ test_files: []