mirror of
https://github.com/frohoff/ysoserial.git
synced 2026-09-21 22:50:46 +08:00
124 lines
3.5 KiB
YAML
124 lines
3.5 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:
|
|
- 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
|
|
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(2) | 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
|
|
steps:
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: jar
|
|
path: jar
|
|
- 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
|
|
if: always()
|
|
with:
|
|
name: out-${{ matrix.version }}
|
|
path: out.txt
|
|
|
|
analyze:
|
|
needs: run-java
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
- run: cat artifacts/out*/*.txt > out.txt
|
|
- run: pip install pytablewriter
|
|
- run: cat out.txt | python .github/workflows/results.py > matrix.md
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: out
|
|
path: out.txt
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: matrix
|
|
path: matrix.md
|
|
|
|
update-wiki:
|
|
needs: analyze
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
repository: ${{github.repository}}.wiki
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: matrix
|
|
- run: |
|
|
git config --local user.email "[email protected]"
|
|
git config --local user.name "GitHub Action"
|
|
git add matrix/matrix.md
|
|
git commit -m "Add changes"
|
|
- uses: ad-m/github-push-action@master
|
|
with:
|
|
repository: ${{github.repository}}.wiki
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|