mirror of
https://github.com/actions/setup-java.git
synced 2024-12-25 08:22:16 -05:00
Merge pull request #49 from ericsciple/users/ericsciple/m166proxy
standardize workflow test pattern
This commit is contained in:
commit
5ef3a8d61b
3 changed files with 84 additions and 32 deletions
92
.github/workflows/workflow.yml
vendored
92
.github/workflows/workflow.yml
vendored
|
@ -1,8 +1,7 @@
|
||||||
name: Main workflow
|
name: Main workflow
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
build:
|
||||||
name: Run
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -10,48 +9,77 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup Node.js 12
|
||||||
- name: Setup Node.js 12.x
|
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 12.x
|
||||||
|
|
||||||
- name: npm install
|
- name: npm install
|
||||||
run: npm install
|
run: npm install
|
||||||
|
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: npm run format-check
|
run: npm run format-check
|
||||||
|
|
||||||
- name: npm test
|
- name: npm test
|
||||||
run: npm test
|
run: npm test
|
||||||
run-with-proxy:
|
|
||||||
name: Run with proxy
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ${{ matrix.operating-system }}
|
||||||
services:
|
strategy:
|
||||||
squid:
|
matrix:
|
||||||
image: dakale/squid
|
operating-system: [ubuntu-latest, windows-latest]
|
||||||
ports: ['3128:3128']
|
|
||||||
options: '--health-cmd "exit 0" --health-interval 3s'
|
|
||||||
env:
|
|
||||||
http_proxy: http://localhost:3128
|
|
||||||
https_proxy: http://localhost:3128
|
|
||||||
steps:
|
steps:
|
||||||
- name: Block non proxied traffic
|
|
||||||
run: |
|
|
||||||
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
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
- name: Clear tool cache
|
||||||
- name: Setup Node.js 12.x
|
if: runner.os != 'windows'
|
||||||
uses: actions/setup-node@v1
|
run: mv "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
|
||||||
|
- name: Clear tool cache (Windows)
|
||||||
|
if: runner.os == 'windows'
|
||||||
|
run: move "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
|
||||||
|
- name: Setup Java 13
|
||||||
|
uses: ./
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
java-version: 13.0.2
|
||||||
|
- name: Verify Java 13
|
||||||
|
if: runner.os != 'windows'
|
||||||
|
run: __tests__/verify-java.sh 13.0.2
|
||||||
|
- name: Verify Java 13 (Windows)
|
||||||
|
if: runner.os == 'windows'
|
||||||
|
run: __tests__/verify-java.ps1 13.0.2
|
||||||
|
|
||||||
- name: npm install
|
test-proxy:
|
||||||
run: npm install
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ubuntu:latest
|
||||||
|
options: --dns 127.0.0.1
|
||||||
|
services:
|
||||||
|
squid-proxy:
|
||||||
|
image: datadog/squid:latest
|
||||||
|
ports:
|
||||||
|
- 3128:3128
|
||||||
|
env:
|
||||||
|
https_proxy: http://squid-proxy:3128
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Clear tool cache
|
||||||
|
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||||
|
- name: Setup Java 13
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
java-version: 13.0.2
|
||||||
|
- name: Verify Java 13
|
||||||
|
run: __tests__/verify-java.sh 13.0.2
|
||||||
|
|
||||||
- name: Lint
|
test-bypass-proxy:
|
||||||
run: npm run format-check
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
- name: npm test
|
https_proxy: http://no-such-proxy:3128
|
||||||
run: npm test
|
no_proxy: github.com,static.azul.com
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Clear tool cache
|
||||||
|
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||||
|
- name: Setup Java 13
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
java-version: 13.0.2
|
||||||
|
- name: Verify Java 13
|
||||||
|
run: __tests__/verify-java.sh 13.0.2
|
||||||
|
|
11
__tests__/verify-java.ps1
Normal file
11
__tests__/verify-java.ps1
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
if (!$args.Count -or !$args[0])
|
||||||
|
{
|
||||||
|
throw "Must supply java version argument"
|
||||||
|
}
|
||||||
|
|
||||||
|
$java_version = & cmd.exe /c "java -version 2>&1" | Out-String
|
||||||
|
Write-Host "Found java version: $java_version"
|
||||||
|
if (!$java_version.Contains($args[0]))
|
||||||
|
{
|
||||||
|
throw "Unexpected version"
|
||||||
|
}
|
13
__tests__/verify-java.sh
Executable file
13
__tests__/verify-java.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Must supply java version argument"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
java_version="$(java -version 2>&1)"
|
||||||
|
echo "Found java version: $java_version"
|
||||||
|
if [ -z "$(echo $java_version | grep --fixed-strings $1)" ]; then
|
||||||
|
echo "Unexpected version"
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Reference in a new issue