Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6dc575e
chore: convert run_macaron.sh unit tests
Jun 26, 2024
b7caaad
chore: convert django tutorial test analyzing dependencies with virtu…
Jun 26, 2024
3da13af
chore: convert case django invalid path to virtual env
Jun 26, 2024
a678d5c
chore: convert case behnazh-w/example-maven-app automatic dependency …
Jun 26, 2024
520a7ff
chore: convert case apache/maven tutorial sbom with no repository
Jun 26, 2024
7895393
chore: convert case apache maven cyclonedx sbom tutorial
Jun 27, 2024
7db8312
chore: convert case test commit finder
Jun 27, 2024
e647c57
chore: convert case repo finder remote calls
Jun 27, 2024
7791872
chore: convert case slsa-verifier with explicit provided provenance url
Jun 27, 2024
4c27872
chore: convert case apache maven analyzing deps with no repo and no sbom
Jun 27, 2024
f8a9ffd
chore: revert deleted files that are used within the unit tests
Jun 27, 2024
89fad35
chore: convert case test not pulling from remote for a local repo
Jun 28, 2024
56ac602
chore: convert case analyzing a local repo with no commit
Jun 28, 2024
1f7550f
chore: convert case test using a repo path outside of local repos dir
Jun 28, 2024
fe5a95b
chore: convert case analyzing with an invalid local repos directory
Jun 28, 2024
8677ed6
chore: convert case analyzing an invalid local repo path
Jun 28, 2024
e6997e2
chore: convert case analyzing a repo that was cloned from another loc…
Jun 28, 2024
6148284
chore: convert case apache maven local paths in configuration and wit…
Jun 28, 2024
84e6327
chore: convert case apache maven local path with branch digest and cy…
Jun 28, 2024
6597f21
chore: convert case jackson databind with purl and no deps
Jun 28, 2024
512334a
chore: convert case apache maven using default template as input temp…
Jun 28, 2024
67748bc
chore: convert case apache maven purl repo path branch commit digest …
Jun 28, 2024
29f8da4
chore: convert case micronaut-test deps resolution compare
Jul 3, 2024
ccec669
chore: convert case jackson databind with purl deps resolution cyclon…
Jul 3, 2024
bb6493b
chore: exclude skip tag for integration tests
Jul 3, 2024
73d0d95
chore: change python3 to python in certain test cases
Jul 3, 2024
cfbc4e8
chore: remove integration tests shell scripts and use the new utility…
Jul 4, 2024
421af9e
chore: update README for integration test, minor fix for Makefile and…
Jul 4, 2024
ebe1240
chore: remove npm-registry tag from gitlab_tinyMediaManager_purl test…
Jul 5, 2024
f339a80
chore: revert wrongly updated copyright date
Jul 5, 2024
274c381
chore: add specific error for the nosec ignore
Jul 5, 2024
4e8011d
chore: ignore specific bandit warning in test_run_macaron_sh.py
Jul 8, 2024
3e3c75c
chore: update template file as input test case and unit test run_maca…
Jul 8, 2024
35810d1
chore: remove e2e/configurations and e2e/expected_results directories
Jul 10, 2024
db144df
chore: fix tab issues in Makefile
Jul 10, 2024
c6b0397
chore: rename compare_e2e_results.py
Jul 11, 2024
40da4ff
chore: fix the integration-docker target in Makefile and improve the …
Jul 11, 2024
a44164f
chore: add note on the reasons for skipped test cases
Jul 15, 2024
2b13c12
chore: change include tag behavior, improve taggings
Jul 15, 2024
d7ed9a5
chore: address grammar and typo errors
Jul 15, 2024
a16877a
chore: address invalid paths in test.yaml for urllib3 test cases
Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,38 @@ test-go:
# Note: to disable npm tests set `NO_NPM` environment variable to `TRUE`.
.PHONY: integration-test
integration-test:
scripts/dev_scripts/integration_tests.sh $(REPO_PATH) "${HOME}"
if [ "${NO_NPM}" == "TRUE" ]; then \
echo "Note: NO_NPM environment variable is set to TRUE, so npm tests will be skipped."; \
python ./tests/integration/run.py \
run \
--include-tag macaron-python-package \
--exclude-tag skip \
--exclude-tag npm-registry-testcase \
./tests/integration/cases/...; \
else \
python ./tests/integration/run.py \
run \
--include-tag macaron-python-package \
--exclude-tag skip \
./tests/integration/cases/...; \
fi

.PHONY: integration-test-docker
integration-test-docker:
scripts/dev_scripts/integration_tests_docker.sh $(REPO_PATH) scripts/release_scripts/run_macaron.sh
python ./tests/integration/run.py \
run \
--macaron scripts/release_scripts/run_macaron.sh \
--include-tag macaron-docker-image \
--exclude-tag skip \
./tests/integration/cases/...

# Update the expected results of the integration tests after generating the actual results.
.PHONY: integration-test-update
integration-test-update:
scripts/dev_scripts/integration_tests.sh $(REPO_PATH) "${HOME}" "--update"
python ./tests/integration/run.py \
update \
--exclude-tag skip \
./tests/integration/cases/...

# Build a source distribution package and a binary wheel distribution artifact.
# When building these artifacts, we need the environment variable SOURCE_DATE_EPOCH
Expand Down
409 changes: 0 additions & 409 deletions scripts/dev_scripts/integration_tests.sh

This file was deleted.

69 changes: 0 additions & 69 deletions scripts/dev_scripts/integration_tests_docker.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Copyright (c) 2023 - 2023, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2022 - 2024, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
2 changes: 0 additions & 2 deletions tests/e2e/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions tests/e2e/configurations/jackson_databind_config.yaml

This file was deleted.

35 changes: 25 additions & 10 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,38 +133,53 @@ $ python ./tests/integration/run.py run ./all/cases/...

In certain cases, we can utilize the feature of tags to select a subset of test cases to run with the `run` command.

Each test case can be attached with one or more tags in the yaml configuration. For example, you may find some of our test cases having the `docker` tag as follows.
Each test case can be attached with one or more tags in the yaml configuration. For example, you may find some of our test cases having the tags as follows.

```yaml
description: ...
tags:
- docker
- macaron-python-package
- macaron-docker-image
steps:
- ...
```

We typically have the test cases for the container image being a subset of the test cases for the Macaron Python package. We can mark the test cases shared for both purposes with the `docker` tag. When we do integration testing for the container image, we can add the argument `--include-tag docker` to filter only test cases tagged with `docker`.
We typically have test cases that are shared for the container image and the Macaron Python package. We can mark the test cases shared for both purposes with `macaron-python-package` and `macaron-docker-image` tags.
When we do integration testing for the container image, we can add the argument `--include-tag macaron-docker-image` to filter test cases that are tagged with `macaron-docker-image`.

```bash
# Test the container image with test cases having the `docker` tag.
$ python ./tests/integration/run.py run --include-tag docker ./all/cases/...
# Test the container image with test cases having the `macaron-docker-image` tag.
$ python ./tests/integration/run.py run --include-tag macaron-docker-image ./all/cases/...
```

The `--include-tag` flag can be specified multiple times. A selected test case must contain all tags specified with the `--include-tag` flag.
We can do the same with `macaron-python-package` when we do integration tests for the Macaron Python package.

The `--include-tag` flag can be specified multiple times. A selected test case must be tagged with at least a tag specified with any of the `--include-tag` flags.

```bash
# Test the container image with test cases having the `docker` tag.
# Test the container image with test cases having EITHER `tag-a` for `tag-b` tag.
$ python ./tests/integration/run.py run --include-tag tag-a --include-tag tag-b ./all/cases/...
```

There is also the `--exclude-tag` flag. A selected test case must also not contain any tag specified with the `--exclude-tag` flag.

```bash
# Only run test cases not tagged with `npm`.
$ python ./tests/integration/run.py run --exclude-tag npm ./all/cases/...
# Only run test cases not tagged with `npm-registry-testcase`.
$ python ./tests/integration/run.py run --exclude-tag npm-registry-testcase ./all/cases/...
```

You can simply think of each `--include-tag`/`--exclude-tag` argument as adding an additional constraint that a selected test case must satisfy".
You can simply think of each `--include-tag`/`--exclude-tag` argument as adding an additional constraint that a selected test case must satisfy.

Instructions on how to tag a test case for our CI/CD pipeline:
- If you want a test case to **only** run for the container image, use **only** `macaron-docker-image`.
- If you want a test case to **only** run with the Macaron Python package, use **only** `macaron-python-package`.
- To skip a test case, use `skip`. `skip` still has the same effect if it's used with other tags.
- If you want to run a test case for both the Macaron Python package and the docker container, use `macaron-python-package` and `macaron-docker-image` tags.
- If you want to run test cases that must contain all of a given set of tags (e.g. `['tag-a', 'tag-b']`), please create an additional tag for those test cases (e.g `tag-a-b`) and use it within `--include-tag`.
- Test cases marked with `npm-registry-testcase` are not run if the environment variable `NO_NPM` is set to `TRUE`. This only applies when you run the integration tests with:
```bash
$ make integration-test
```

### Debug utility script

Expand Down
3 changes: 3 additions & 0 deletions tests/integration/cases/all_checks_excluded/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
description: |
Running the analysis with all checks excluded. This test should return an error code.

tags:
- macaron-python-package

steps:
- name: Run macaron analyze
kind: analyze
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.

description: |
Analyzing dependencies when neither the repository nor SBOM is available. We expect the analysis to finish with no errors.

tags:
- macaron-python-package

steps:
- name: Run macaron analyze
kind: analyze
options:
command_args:
- -purl
- pkg:maven/private.apache.maven/maven@4.0.0-alpha-1-SNAPSHOT?type=pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.

description: |
Analyzing a repository that was cloned from another local repo.

tags:
- macaron-python-package

steps:
- name: Clone the apache maven repository
kind: shell
options:
# We don't want to perform a treeless clone here. This is because
# we later make another clone of this repository at output/git_repos/local_repos/maven.
# A clone from output/git_repos/local_repos/maven will have its remote pointing to this
# local path output/git_repos/local_repos/maven. If output/git_repos/local_repos/maven is treeless,
# then any clone from it will not be able to checkout previous commit due to its trees and blobs missing.
cmd: git clone https://github.com/apache/maven output/git_repos/local_repos/maven
- name: Make a clone from the maven repository
kind: shell
options:
cmd: git clone output/git_repos/local_repos/maven output/git_repos/local_repos/second_maven
- name: Run macaron analyze
kind: analyze
options:
main_args:
- -lr
- ./output/git_repos/local_repos
command_args:
- -rp
- second_maven
- -b
- master
- -d
- 3fc399318edef0d5ba593723a24fff64291d6f9b
- --skip-deps
# We don't compare the report content because the remote_path fields in the reports are nondeterministic when running
# this test locally and running it in the GitHub Actions runner. We only check if the reports are generated as
# expected without the issue described in https://github.com/oracle/macaron/issues/116.
- name: Check if the JSON report is generated in the expected location
kind: shell
options:
cmd: ls output/reports/local_repos/maven/maven.json
- name: Check if the HTML report is generated in the expected location
kind: shell
options:
cmd: ls output/reports/local_repos/maven/maven.html
Loading