diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index af6ad9d7e..7cbfd2f12 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -94,7 +94,7 @@ jobs: - uses: actions/checkout@v4 - uses: projectdiscovery/actions/setup/go@v1 - uses: projectdiscovery/actions/setup/python@v1 - - run: bash run.sh "${{ matrix.os }}" + - run: bash run.sh env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" working-directory: cmd/functional-test/ diff --git a/cmd/functional-test/main.go b/cmd/functional-test/main.go index 8a5cebc59..78114fdb3 100644 --- a/cmd/functional-test/main.go +++ b/cmd/functional-test/main.go @@ -27,7 +27,7 @@ var ( func main() { flag.Parse() - debug := os.Getenv("DEBUG") == "true" + debug := os.Getenv("DEBUG") == "true" || os.Getenv("RUNNER_DEBUG") == "1" if err, errored := runFunctionalTests(debug); err != nil { log.Fatalf("Could not run functional tests: %s\n", err) diff --git a/cmd/functional-test/run.sh b/cmd/functional-test/run.sh index a3caf7222..a955ad8a7 100755 --- a/cmd/functional-test/run.sh +++ b/cmd/functional-test/run.sh @@ -1,27 +1,43 @@ #!/bin/bash -# reading os type from arguments -CURRENT_OS=$1 +if [ "${RUNNER_OS}" == "Windows" ]; then + EXT=".exe" +elif [ "${RUNNER_OS}" == "macOS" ]; then + if [ "${CI}" == "true" ]; then + sudo sysctl -w kern.maxfiles{,perproc}=524288 + sudo launchctl limit maxfiles 65536 524288 + fi -if [ "${CURRENT_OS}" == "windows-latest" ];then - extension=.exe + ORIGINAL_ULIMIT="$(ulimit -n)" + ulimit -n 65536 || true fi +mkdir -p .nuclei-config/nuclei/ +touch .nuclei-config/nuclei/.nuclei-ignore + echo "::group::Building functional-test binary" -go build -o functional-test$extension +go build -o "functional-test${EXT}" echo "::endgroup::" echo "::group::Building Nuclei binary from current branch" -go build -o nuclei_dev$extension ../nuclei -echo "::endgroup::" - -echo "::group::Installing nuclei templates" -./nuclei_dev$extension -update-templates +go build -o "nuclei-dev${EXT}" ../nuclei echo "::endgroup::" echo "::group::Building latest release of nuclei" -go build -o nuclei$extension -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei +go build -o "nuclei${EXT}" -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei echo "::endgroup::" -echo 'Starting Nuclei functional test' -./functional-test$extension -main ./nuclei$extension -dev ./nuclei_dev$extension -testcases testcases.txt +echo "::group::Installing nuclei templates" +eval "./nuclei-dev${EXT} -update-templates" +echo "::endgroup::" + +echo "::group::Validating templates" +eval "./nuclei-dev${EXT} -validate" +echo "::endgroup::" + +echo "Starting Nuclei functional test" +eval "./functional-test${EXT} -main ./nuclei${EXT} -dev ./nuclei-dev${EXT} -testcases testcases.txt" + +if [ "${RUNNER_OS}" == "macOS" ]; then + ulimit -n "${ORIGINAL_ULIMIT}" || true +fi