mirror of
https://github.com/frohoff/ysoserial.git
synced 2026-09-21 22:50:46 +08:00
116 lines
3.2 KiB
YAML
116 lines
3.2 KiB
YAML
# https://michaelheap.com/dynamic-matrix-generation-github-actions/
|
|
|
|
name: test
|
|
on: [push]
|
|
jobs:
|
|
# TODO cache build output by commit
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- run: which node && node --version && env
|
|
- run: docker run --rm vulhub/java:7u21-jdk java -version
|
|
|
|
- if: ${{ env.ACT }} # act workaround
|
|
run: sudo chown -R runner:runner /var/run/act
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- if: ${{ env.ACT }} # act workaround
|
|
run: sudo chown -R runner:runner .
|
|
|
|
|
|
- name: Set up JDK 1.8
|
|
uses: actions/setup-java@v2
|
|
with:
|
|
java-version: 8
|
|
distribution: adopt
|
|
|
|
- if: ${{ !env.ACT }} # use -r with act
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ~/.m2/repository
|
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-maven-
|
|
|
|
- run: mvn -B clean package -DskipTests
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: jar
|
|
path: target/ysoserial-*-all.jar
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: results
|
|
path: .github/workflows/results.py
|
|
|
|
set-matrix:
|
|
runs-on: ubuntu-latest
|
|
container: dwdraju/alpine-curl-jq
|
|
steps:
|
|
- id: get-versions
|
|
# TODO paging
|
|
run: |
|
|
URL="https://hub.docker.com/v2/repositories/vulhub/java/tags/?page_size=100"
|
|
VERSIONS=$(curl -s $URL "$URL&page=2" | jq -rc '[[.results[].name] | _nwise(3) | join(" ")]')
|
|
echo "::set-output name=versions::$VERSIONS"
|
|
|
|
outputs:
|
|
versions: ${{ steps.get-versions.outputs.versions }}
|
|
|
|
run-java:
|
|
needs:
|
|
- set-matrix
|
|
- build
|
|
strategy:
|
|
matrix:
|
|
version: ${{ fromJson(needs.set-matrix.outputs.versions) }} # broken in act
|
|
# version:
|
|
# - 7u21-jdk 7u25-jdk
|
|
# - 7u40-jdk
|
|
runs-on: ubuntu-latest
|
|
# container:
|
|
# image: vulhub/java:${{ matrix.version }}
|
|
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: jar
|
|
path: jar
|
|
# - run: java -cp jar/ysoserial-*-all.jar -DforceTests=true ysoserial.test.payloads.PayloadsTest | tee > out.txt
|
|
- run: pwd
|
|
- run: mv jar/ysoserial-*-all.jar jar/ysoserial.jar
|
|
- run: |
|
|
touch out.txt
|
|
for v in ${{ matrix.version }}; do
|
|
echo running $v
|
|
docker pull vulhub/java:$v
|
|
docker run --rm -v $(pwd):/app vulhub/java:$v java -cp '/app/jar/ysoserial.jar' -DforceTests=true ysoserial.test.payloads.PayloadsTest >> out.txt
|
|
done
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: out-${{ matrix.version }}
|
|
path: out.txt
|
|
|
|
analyze:
|
|
needs: run-java
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
- run: cat artifacts/out*/*.txt > out.txt
|
|
- run: pip install pytablewriter
|
|
- run: cat out.txt | python artifacts/results/results.py > matrix.md
|
|
- uses: actions/upload-artifact@v3
|
|
if: always()
|
|
with:
|
|
name: out
|
|
path: out.txt
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: matrix
|
|
path: matrix.md
|