feat: add pregen to setup environment #986
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test BOM Snapshots | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
- release/* | |
tags: | |
- 'v*' | |
pull_request: | |
paths-ignore: | |
- 'docs/**' | |
- '*.md' | |
concurrency: | |
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}" | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
pregen: | |
runs-on: ubuntu-latest | |
outputs: | |
venv_path: ${{ steps.set_env.outputs.venv_path }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Create venv and install prerequisites | |
id: set_env | |
run: | | |
echo "pwd:" | |
pwd | |
ls -al .venv | |
python3.12 -m venv .venv | |
echo "VENV_PATH=$(pwd)/.venv" >> $GITHUB_ENV | |
source .venv/bin/activate | |
pip install setuptools wheel | |
test_non_dotnet: | |
runs-on: ["snapshot-test"] | |
needs: pregen | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up pnpm | |
uses: pnpm/action-setup@v4 | |
- name: Debug paths | |
run: | | |
echo "VENV_PATH: ${{ needs.pregen.outputs.venv_path }}" | |
echo "Running pwd to confirm the directory:" | |
pwd | |
ls -al ${{ needs.pregen.outputs.venv_path }} # Path access verification | |
- name: cdxgen, custom-json-diff installs | |
shell: bash | |
env: | |
SHELL: bash | |
run: | | |
rm -rf original_snapshots new_snapshots src_repos | |
cdxgen_tarball=$(pnpm pack | tail -1) | |
sudo npm install -g "$cdxgen_tarball" | |
git clone https://github.com/appthreat/cdxgen-samples.git original_snapshots | |
source ${{ needs.pregen.outputs.venv_path }}/bin/activate | |
pip install -r test/diff/requirements.txt | |
- name: Generate scripts | |
run: | | |
source ${{ needs.pregen.outputs.venv_path }}/bin/activate | |
python test/diff/generate.py | |
env: | |
ATOM_JAVA_HOME: /usr/lib/jvm/java-21-openjdk-amd64 | |
- name: Upload shell scripts generated as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: scripts | |
path: new_snapshots/*.sh | |
- name: Run scripts | |
env: | |
PREFER_MAVEN_DEPS_TREE: false | |
ATOM_JAVA_HOME: /usr/lib/jvm/java-21-openjdk-amd64 | |
run: | | |
bash new_snapshots/cdxgen_commands.sh | |
- name: Upload cdxgen boms | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cdxgen_boms | |
path: | | |
new_snapshots | |
- name: Test BOMs | |
run: | | |
source ${{ needs.pregen.outputs.venv_path }}/bin/activate | |
python test/diff/diff_tests.py --migrate-legacy | |
if test -f new_snapshots/diffs.json; then | |
echo "status=FAILED" >> $GITHUB_ENV | |
fi | |
- name: Upload diff | |
if: ${{ env.status == 'FAILED' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: diffs | |
path: | | |
new_snapshots/diffs.json | |
new_snapshots/*.html | |
- name: Exit with error | |
if: ${{ env.status == 'FAILED' }} | |
run: exit 1 |