Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 5ef3a8d

Browse files
authored
Merge pull request actions#49 from ericsciple/users/ericsciple/m166proxy
standardize workflow test pattern
2 parents f63b906 + 60cf21b commit 5ef3a8d

File tree

3 files changed

+84
-32
lines changed

3 files changed

+84
-32
lines changed

.github/workflows/workflow.yml

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,85 @@
11
name: Main workflow
22
on: [push, pull_request]
33
jobs:
4-
run:
5-
name: Run
4+
build:
65
runs-on: ${{ matrix.operating-system }}
76
strategy:
87
matrix:
98
operating-system: [ubuntu-latest, windows-latest]
109
steps:
1110
- name: Checkout
1211
uses: actions/checkout@v2
13-
14-
- name: Setup Node.js 12.x
12+
- name: Setup Node.js 12
1513
uses: actions/setup-node@v1
1614
with:
1715
node-version: 12.x
18-
1916
- name: npm install
2017
run: npm install
21-
2218
- name: Lint
2319
run: npm run format-check
24-
2520
- name: npm test
2621
run: npm test
27-
run-with-proxy:
28-
name: Run with proxy
29-
runs-on: ubuntu-latest
30-
services:
31-
squid:
32-
image: dakale/squid
33-
ports: ['3128:3128']
34-
options: '--health-cmd "exit 0" --health-interval 3s'
35-
env:
36-
http_proxy: http://localhost:3128
37-
https_proxy: http://localhost:3128
22+
23+
test:
24+
runs-on: ${{ matrix.operating-system }}
25+
strategy:
26+
matrix:
27+
operating-system: [ubuntu-latest, windows-latest]
3828
steps:
39-
- name: Block non proxied traffic
40-
run: |
41-
echo "127.0.0.0 registry.npm.js nodejs.org github.com api.github.com download.java.net static.azul.com" | sudo tee -a /etc/hosts
4229
- name: Checkout
4330
uses: actions/checkout@v2
44-
45-
- name: Setup Node.js 12.x
46-
uses: actions/setup-node@v1
31+
- name: Clear tool cache
32+
if: runner.os != 'windows'
33+
run: mv "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
34+
- name: Clear tool cache (Windows)
35+
if: runner.os == 'windows'
36+
run: move "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
37+
- name: Setup Java 13
38+
uses: ./
4739
with:
48-
node-version: 12.x
40+
java-version: 13.0.2
41+
- name: Verify Java 13
42+
if: runner.os != 'windows'
43+
run: __tests__/verify-java.sh 13.0.2
44+
- name: Verify Java 13 (Windows)
45+
if: runner.os == 'windows'
46+
run: __tests__/verify-java.ps1 13.0.2
4947

50-
- name: npm install
51-
run: npm install
52-
53-
- name: Lint
54-
run: npm run format-check
48+
test-proxy:
49+
runs-on: ubuntu-latest
50+
container:
51+
image: ubuntu:latest
52+
options: --dns 127.0.0.1
53+
services:
54+
squid-proxy:
55+
image: datadog/squid:latest
56+
ports:
57+
- 3128:3128
58+
env:
59+
https_proxy: http://squid-proxy:3128
60+
steps:
61+
- uses: actions/checkout@v2
62+
- name: Clear tool cache
63+
run: rm -rf $RUNNER_TOOL_CACHE/*
64+
- name: Setup Java 13
65+
uses: ./
66+
with:
67+
java-version: 13.0.2
68+
- name: Verify Java 13
69+
run: __tests__/verify-java.sh 13.0.2
5570

56-
- name: npm test
57-
run: npm test
71+
test-bypass-proxy:
72+
runs-on: ubuntu-latest
73+
env:
74+
https_proxy: http://no-such-proxy:3128
75+
no_proxy: github.com,static.azul.com
76+
steps:
77+
- uses: actions/checkout@v2
78+
- name: Clear tool cache
79+
run: rm -rf $RUNNER_TOOL_CACHE/*
80+
- name: Setup Java 13
81+
uses: ./
82+
with:
83+
java-version: 13.0.2
84+
- name: Verify Java 13
85+
run: __tests__/verify-java.sh 13.0.2

__tests__/verify-java.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (!$args.Count -or !$args[0])
2+
{
3+
throw "Must supply java version argument"
4+
}
5+
6+
$java_version = & cmd.exe /c "java -version 2>&1" | Out-String
7+
Write-Host "Found java version: $java_version"
8+
if (!$java_version.Contains($args[0]))
9+
{
10+
throw "Unexpected version"
11+
}

__tests__/verify-java.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
if [ -z "$1" ]; then
4+
echo "Must supply java version argument"
5+
exit 1
6+
fi
7+
8+
java_version="$(java -version 2>&1)"
9+
echo "Found java version: $java_version"
10+
if [ -z "$(echo $java_version | grep --fixed-strings $1)" ]; then
11+
echo "Unexpected version"
12+
exit 1
13+
fi

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy