Skip to content

Commit d7ce050

Browse files
authored
[semver:patch] Add support for Windows builds (#87)
* Add macos * fix * Add windows * Use orbs * python/dist * Redo configuration * fixes * add versions * npm install * fix a thing * re-jigger * remove artifacts * typo * workspaces * Update orb for windows * Try adding windows * Try equals * hackity hack * more hacks * maybe * more complexity * update config * Try something else * executors * dot name * echo * no matrix * brackets * matrix? * alias * try powershell * powershell * 1.2.1 and splatting * fixes * change * logs * more things * more logging * Edit logging and dont call bash * more fixing * small change * execute * a dot * a thing * all the args * now with bahs * Logging * xtra_args * typo * no bash? * dot sh * dot slash * sh * splat * bash * try no args * comma * to nothing * is it just me * Test * Splat a hash * true * end bracket * quotes * quotes * log arguments * back to arrays * real array * Add in additional args * rejigger * comma * more if * upload_name
1 parent b38ae52 commit d7ce050

File tree

6 files changed

+167
-47
lines changed

6 files changed

+167
-47
lines changed

.circleci/config.yml

+75-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ version: 2.1
44
# release must exist.);
55
orbs:
66
codecov: codecov/codecov@dev:alpha
7+
node: circleci/[email protected]
78
orb-tools: circleci/[email protected]
9+
python: circleci/[email protected]
10+
win: circleci/[email protected]
811

912
# Pipeline parameters
1013
parameters:
@@ -17,38 +20,73 @@ parameters:
1720
type: string
1821
default: "dev:alpha"
1922

23+
executors:
24+
linux:
25+
docker:
26+
- image: cimg/base:stable
27+
macos:
28+
macos:
29+
xcode: 11.4
30+
windows: win/default
31+
32+
python:
33+
docker:
34+
- image: cimg/python:3.9.5
35+
node:
36+
docker:
37+
- image: cimg/node:16.2.0
38+
2039
jobs:
2140
# This job is an example of an integration testing job.
2241
# This job should execute a command from your orb and verify
2342
# the output is as expected, otherwise the job should fail.
2443
#
2544
# Rename this job and add more as needed.
2645
#
27-
integration-test:
28-
docker:
29-
- image: cimg/base:stable
46+
test-backend:
47+
executor: python
3048
steps:
3149
- checkout
32-
- run: sudo apt-get update
33-
- run: sudo apt-get install python3
34-
- run: sudo apt-get install python3-pip
35-
- run: sudo python3 -m pip install --upgrade pip
36-
- run: sudo pip install -r requirements.txt
50+
- python/install-packages:
51+
pkg-manager: pip
3752
- run: python3 -m pytest --junitxml=junit/test-results.xml --cov=src --cov-report=xml --cov-report=html test/unit
38-
- codecov/upload:
39-
flags: backend
40-
41-
- run: sudo apt-get install npm
42-
- run: sudo npm install -g [email protected]
53+
- persist_to_workspace:
54+
root: .
55+
paths:
56+
- coverage.xml
57+
test-frontend:
58+
executor: node
59+
steps:
60+
- checkout
61+
- node/install-npm
4362
- run: npm install
4463
- run: npm test
64+
- persist_to_workspace:
65+
root: .
66+
paths:
67+
- coverage/coverage-final.json
68+
test-codecov-orb:
69+
parameters:
70+
os:
71+
type: executor
72+
using_windows:
73+
type: boolean
74+
executor: << parameters.os >>
75+
steps:
76+
- checkout
77+
- attach_workspace:
78+
at: .
79+
- codecov/upload:
80+
flags: backend
81+
using_windows: << parameters.using_windows >>
4582
- codecov/upload:
4683
file: coverage/coverage-final.json
4784
flags: frontend
85+
using_windows: << parameters.using_windows >>
4886
xtra_args: -v -Z
4987

88+
5089
workflows:
51-
# This `lint-pack_validate_publish-dev` workflow will run on any commit.
5290
test-pack:
5391
unless: << pipeline.parameters.run-integration-tests >>
5492
jobs:
@@ -57,6 +95,7 @@ workflows:
5795
- hold:
5896
type: approval # presents manual approval button in the UI
5997
requires:
98+
- orb-tools/lint
6099
- orb-tools/pack
61100

62101
# release dev version of orb, for testing & possible publishing.
@@ -79,10 +118,26 @@ workflows:
79118
integration-tests_deploy:
80119
when: << pipeline.parameters.run-integration-tests >>
81120
jobs:
82-
# your integration test jobs go here: essentially, run all your orb's
83-
# jobs and commands to ensure they behave as expected. or, run other
84-
# integration tests of your choosing
85-
- integration-test
121+
- test-backend
122+
- test-frontend
123+
- test-codecov-orb:
124+
matrix:
125+
alias: test-codecov-orb-non-windows
126+
parameters:
127+
os: [linux, macos]
128+
using_windows: [false]
129+
requires:
130+
- test-backend
131+
- test-frontend
132+
- test-codecov-orb:
133+
matrix:
134+
alias: test-codecov-orb-windows
135+
parameters:
136+
os: [windows]
137+
using_windows: [true]
138+
requires:
139+
- test-backend
140+
- test-frontend
86141

87142
- orb-tools/dev-promote-prod-from-commit-subject:
88143
add-pr-comment: false
@@ -95,4 +150,5 @@ workflows:
95150
publish-version-tag: false
96151
publish-token-variable: ORB_PUBLISH_TOKEN
97152
requires:
98-
- integration-test
153+
- test-codecov-orb-non-windows
154+
- test-codecov-orb-windows

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.2.1
2+
**Fixes**
3+
- #87 Fix support for Windows executors
4+
15
## 1.2.0
26
**Features**
37
- #84 Allow extra parameters to be specified from the bash uploader

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# codecov-circleci-orb
22

3-
## Latest version 1.1.6
3+
## Latest version 1.2.1
44

55
[![codecov.io](https://codecov.io/github/codecov/codecov-circleci-orb/coverage.svg?branch=master)](https://codecov.io/github/codecov/codecov-circleci-orb)
66
[![Circle CI](https://circleci.com/gh/codecov/codecov-circleci-orb.png?style=badge)](https://circleci.com/gh/codecov/codecov-circleci-orb)

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codecov-circleci-orb",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Codecov CircleCI Orb",
55
"main": "index.js",
66
"devDependencies": {

src/@orb.yml

+85-25
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ commands:
2929
description: Custom url to submit the codecov result. Default to "https://codecov.io/bash"
3030
type: string
3131
default: "https://codecov.io/bash"
32+
using_windows:
33+
description: Is this being run in a Windows setup?
34+
type: boolean
35+
default: false
3236
validate_url:
3337
description: Validate the url before submitting the codecov result. https://docs.codecov.io/docs/about-the-codecov-bash-uploader#validating-the-bash-script
3438
type: boolean
@@ -38,35 +42,91 @@ commands:
3842
type: string
3943
default: "always"
4044
xtra_args:
41-
description: Any extra flags as provided by the bash uploader (e.g. `-v -Z`)
45+
description: Any extra flags as provided by the bash uploader (e.g. `-v -Z`).
4246
type: string
4347
default: ""
4448
steps:
45-
- run:
46-
name: Download Codecov Bash Uploader
47-
command: curl -fLso codecov << parameters.url >>
48-
when: << parameters.when >>
4949
- when:
50-
condition: << parameters.validate_url >>
50+
condition: << parameters.using_windows >>
5151
steps:
5252
- run:
53-
name: Validate Codecov Bash Uploader
54-
command: |
55-
VERSION=$(grep 'VERSION=\"[0-9\.]*\"' codecov | cut -d'"' -f2);
56-
for i in 1 256 512
57-
do
58-
shasum -a $i -c --ignore-missing <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA${i}SUM) ||
59-
shasum -a $i -c <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA${i}SUM | grep -w "codecov")
60-
done
53+
name: Download Codecov Bash Uploader
54+
command: curl -Outfile codecov -Uri << parameters.url >>
55+
when: << parameters.when >>
56+
- when:
57+
condition: << parameters.validate_url >>
58+
steps:
59+
- run:
60+
name: Validate Codecov Bash Uploader
61+
command: |
62+
$VERSION=((Select-String -path codecov 'VERSION=\"[0-9\.]*\"' | ForEach-Object {$_.Matches} | Foreach-Object {$_.Groups[0].Value})-split '"')[1]
63+
foreach ($i in 1, 256, 512) {
64+
$hash = (((curl "https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA${i}SUM")[0])-split( " " ))[0]
65+
$scripthash = (Get-FileHash -Algorithm "SHA${i}" codecov).hash.ToLower()
66+
If ($scripthash -ne $hash) {
67+
echo "Script hash: ${scripthash}"
68+
echo "Published has: ${hash}"
69+
echo "SHASUMs do not match, exiting."
70+
exit 1
71+
} Else {
72+
echo "OK"
73+
}
74+
}
75+
- run:
76+
name: Upload Coverage Results
77+
command: |
78+
$arguments = @( "-Q", "codecov-circleci-orb-1.2.1" )
79+
If ( "<< parameters.token >>" -ne "") {
80+
$arguments += "-t"
81+
$arguments += "<< parameters.token >>"
82+
}
83+
If ( "<< parameters.flags >>" -ne "") {
84+
$arguments += "-F"
85+
$arguments += "<< parameters.flags >>"
86+
}
87+
If ( "<< parameters.file >>" -ne "") {
88+
$arguments += "-f"
89+
$arguments += "<< parameters.file >>"
90+
}
91+
If ( "<< parameters.upload_name >>" -ne "") {
92+
$arguments += "-n"
93+
$arguments += "<< parameters.upload_name >>"
94+
}
95+
If ( "<< parameters.xtra_args >>" -ne "") {
96+
foreach ($arg in "<< parameters.xtra_args >>".split( " " ) ) {
97+
$arguments += $arg
98+
}
99+
}
100+
chmod +x codecov
101+
bash ./codecov @arguments
102+
- unless:
103+
condition: << parameters.using_windows >>
104+
steps:
61105
- run:
62-
name: Upload Coverage Results
63-
command: |
64-
args=()
65-
[[ -n "<< parameters.file >>" ]] && args+=( '-f << parameters.file >>' )
66-
[[ -n "<< parameters.xtra_args >>" ]] && args+=( '<< parameters.xtra_args >>' )
67-
bash codecov \
68-
-Q "codecov-circleci-orb-1.2.0" \
69-
-t "<< parameters.token >>" \
70-
-n "<< parameters.upload_name >>" \
71-
-F "<< parameters.flags >>" \
72-
${args[@]}
106+
name: Download Codecov Bash Uploader
107+
command: curl -fLso codecov << parameters.url >>
108+
when: << parameters.when >>
109+
- when:
110+
condition: << parameters.validate_url >>
111+
steps:
112+
- run:
113+
name: Validate Codecov Bash Uploader
114+
command: |
115+
VERSION=$(grep 'VERSION=\"[0-9\.]*\"' codecov | cut -d'"' -f2);
116+
for i in 1 256 512
117+
do
118+
shasum -a $i -c --ignore-missing <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA${i}SUM) ||
119+
shasum -a $i -c <(curl -s https://raw.githubusercontent.com/codecov/codecov-bash/${VERSION}/SHA${i}SUM | grep -w "codecov")
120+
done
121+
- run:
122+
name: Upload Coverage Results
123+
command: |
124+
args=()
125+
[[ -n "<< parameters.file >>" ]] && args+=( '-f << parameters.file >>' )
126+
[[ -n "<< parameters.xtra_args >>" ]] && args+=( '<< parameters.xtra_args >>' )
127+
bash codecov \
128+
-Q "codecov-circleci-orb-1.2.1" \
129+
-t "<< parameters.token >>" \
130+
-n "<< parameters.upload_name >>" \
131+
-F "<< parameters.flags >>" \
132+
${args[@]}

0 commit comments

Comments
 (0)