FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
shfmt/.github/workflows/test.yml at master · patrickvane/shfmt · GitHub
patrickvane
/
shfmt
Public
forked from
mvdan/sh
Notifications
You must be signed in to change notification settings
Fork
6
Star
191
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
shfmt
/
.github
/
workflows
/
test.yml
Copy path
View runs
More file actions
More file actions
Latest commit
History
History
History
187 lines (175 loc) · 6.57 KB
Breadcrumbs
shfmt
/
.github
/
workflows
/
test.yml
Copy path
File metadata and controls
187 lines (175 loc) · 6.57 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
on
:
[push, pull_request]
name
:
Go
jobs
:
test
:
strategy
:
matrix
:
go-version
:
[1.13.x, 1.14.x]
platform
:
[ubuntu-latest, macos-latest, windows-latest]
runs-on
:
${{ matrix.platform }}
steps
:
-
name
:
Install Go
uses
:
actions/setup-go@v1
with
:
go-version
:
${{ matrix.go-version }}
-
name
:
Checkout code
uses
:
actions/checkout@v2
-
name
:
Test
run
:
go test -count=1 ./...
-
name
:
Test with -short -race
run
:
go test -short -race -count=1 ./...
-
name
:
Test with GOARCH=386
run
:
GOARCH=386 go test -count=1 ./...
if
:
matrix.platform == 'ubuntu-latest'
-
name
:
gofmt check
run
:
diff <(echo -n) <(gofmt -d .)
if
:
matrix.platform == 'ubuntu-latest'
test-linux-alpine
:
runs-on
:
ubuntu-latest
steps
:
-
name
:
Checkout code
uses
:
actions/checkout@v2
-
name
:
Test as root, without cgo, and with busybox
run
:
docker run -v="$PWD:/pwd" -w=/pwd -e=CGO_ENABLED=0 golang:1.14.3-alpine go test ./...
docker
:
name
:
Build and deploy Docker images
#
Only deploy if previous stages pass.
needs
:
[test, test-linux-alpine]
runs-on
:
ubuntu-latest
if
:
>
github.event_name == 'push' &&
(github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/tags/')) &&
github.repository == 'mvdan/sh'
env
:
#
Export environment variables for all stages.
DOCKER_CLI_EXPERIMENTAL
:
enabled
#
for 'docker buildx'
DOCKER_USER
:
mvdan
DOCKER_PASSWORD
:
${{secrets.DOCKER_PASSWORD}}
DOCKER_REPO
:
shfmt
#
We use all platforms for which FROM images in our Dockerfile are
#
available.
DOCKER_PLATFORMS
:
>
linux/386
linux/amd64
linux/arm/v7
linux/arm64/v8
linux/ppc64le
#
linux/s390x TODO: reenable when we figure out its weird errors when
#
fetching dependencies, including:
#
#
zip: checksum error
#
Get "https://proxy.golang.org/...": local error: tls: bad record MAC
#
Get "https://proxy.golang.org/...": local error: tls: unexpected message
#
Get "https://proxy.golang.org/...": x509: certificate signed by unknown authority
steps
:
-
name
:
Checkout code
uses
:
actions/checkout@v2
with
:
fetch-depth
:
0
#
also fetch tags for 'git describe'
-
name
:
Set up image tag
run
:
|
set -vx
# Export environment variable for later stages.
if echo "$GITHUB_REF" | grep -q '^refs/heads/'; then
# Pushes to (master) branch - deploy 'latest'.
echo "::set-env name=TAG::latest"
elif echo "$GITHUB_REF" | grep -q '^refs/tags/'; then
# Pushes tag - deploy tag name.
echo "::set-env name=TAG::${GITHUB_REF/refs\/tags\//}"
fi
echo "::set-env name=DOCKER_BASE::${DOCKER_USER}/${DOCKER_REPO}"
-
name
:
Install Docker buildx
run
:
|
set -vx
# Install up-to-date version of docker, with buildx support.
docker_apt_repo='https://download.docker.com/linux/ubuntu'
curl -fsSL "${docker_apt_repo}/gpg" | sudo apt-key add -
os="$(lsb_release -cs)"
sudo add-apt-repository "deb [arch=amd64] $docker_apt_repo $os stable"
sudo apt-get update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
# Enable docker daemon experimental support (for 'pull --platform').
config='/etc/docker/daemon.json'
if [[ -e "$config" ]]; then
sudo sed -i -e 's/{/{ "experimental": true, /' "$config"
else
echo '{ "experimental": true }' | sudo tee "$config"
fi
sudo systemctl restart docker
# Install QEMU multi-architecture support for docker buildx.
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# Instantiate docker buildx builder with multi-architecture support.
docker buildx create --name mybuilder
docker buildx use mybuilder
# Start up buildx and verify that all is OK.
docker buildx inspect --bootstrap
-
name
:
Build multi-architecture Docker images with buildx
run
:
|
set -vx
echo "$DOCKER_PASSWORD" \
| docker login -u="$DOCKER_USER" --password-stdin
function buildx() {
docker buildx build \
--platform ${DOCKER_PLATFORMS// /,} \
--push \
-f cmd/shfmt/Dockerfile \
"$@" \
.
}
buildx -t "$DOCKER_BASE:$TAG"
buildx -t "$DOCKER_BASE:$TAG-alpine" --target alpine
-
name
:
Test multi-architecture Docker images
run
:
|
printf '%s\n' "#!/bin/sh" "echo 'hello world'" >myscript
for platform in $DOCKER_PLATFORMS; do
for ext in '' '-alpine'; do
image="${DOCKER_BASE}:${TAG}${ext}"
msg="Testing docker image $image on platform $platform"
line="${msg//?/=}"
printf "\n${line}\n${msg}\n${line}\n"
docker pull -q --platform "$platform" "$image"
if [ -n "$ext" ]; then
echo -n "Image architecture: "
docker run --rm --entrypoint /bin/sh "$image" -c 'uname -m'
fi
version=$(docker run --rm "$image" --version)
echo "shfmt version: $version"
if [ "$TAG" != 'latest' -a "$TAG" != "$version" ]; then
echo "Version mismatch: shfmt $version tagged as $TAG"
exit 1
fi
docker run --rm -v "$PWD:/mnt" -w '/mnt' "$image" -d myscript
done
done
-
name
:
Install Node.js
uses
:
actions/setup-node@v1
with
:
node-version
:
13.x
-
name
:
Update DockerHub description
run
:
|
set -vx
npm install docker-hub-api@0.8.0
node -e '
function error(reason) {
console.log("Error: " + reason.message);
process.exit(1);
}
const fs = require("fs");
let readme = fs.readFileSync("README.md", "utf8");
let dockerHubAPI = require("docker-hub-api");
dockerHubAPI.login(
process.env.DOCKER_USER,
process.env.DOCKER_PASSWORD)
.then(function () {
let url = "https://github.com/" + process.env.GITHUB_REPOSITORY;
let repo = process.env.DOCKER_REPO;
dockerHubAPI.setRepositoryDescription(
process.env.DOCKER_USER,
repo,
{short: "Official " + repo + " images from " + url,
full: readme})
.catch(reason => error(reason));
})
.catch(reason => error(reason));
'
Back
|
FazBrowse Home
|
New Git URL