diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41c776c..a15523a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,21 +1,47 @@ name: ci on: -- pull_request -- push + push: + branches: + - master + paths-ignore: + - '*.md' + pull_request: + paths-ignore: + - '*.md' + +# Cancel in progress workflows +# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run +concurrency: + group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" + cancel-in-progress: true jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 'lts/*' + + - name: Install dependencies + run: npm install --ignore-scripts --only=dev + + - name: Run lint + run: npm run lint + test: - runs-on: ubuntu-20.04 strategy: + fail-fast: false matrix: + os: [ubuntu-latest, windows-latest] name: - Node.js 0.8 - Node.js 0.10 - Node.js 0.12 - - io.js 1.x - - io.js 2.x - - io.js 3.x - Node.js 4.x - Node.js 5.x - Node.js 6.x @@ -35,6 +61,7 @@ jobs: - Node.js 20.x - Node.js 21.x - Node.js 22.x + - Node.js 23.x include: - name: Node.js 0.8 @@ -45,22 +72,12 @@ jobs: - name: Node.js 0.10 node-version: "0.10" npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1 + npm-version: "npm@2.15.1" - name: Node.js 0.12 node-version: "0.12" npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1 - - - name: io.js 1.x - node-version: "1.8" - npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1 - - - name: io.js 2.x - node-version: "2.5" - npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1 - - - name: io.js 3.x - node-version: "3.3" - npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1 + npm-version: "npm@2.15.1" - name: Node.js 4.x node-version: "4.9" @@ -69,6 +86,7 @@ jobs: - name: Node.js 5.x node-version: "5.12" npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2 + npm-version: npm@3.10.10 - name: Node.js 6.x node-version: "6.17" @@ -107,59 +125,72 @@ jobs: npm-i: supertest@6.1.3 - name: Node.js 15.x - node-version: "15.14" + node-version: "15" npm-i: supertest@6.1.3 - name: Node.js 16.x - node-version: "16.20" + node-version: "16" npm-i: supertest@6.1.3 - name: Node.js 17.x - node-version: "17.9" + node-version: "17" npm-i: supertest@6.1.3 - name: Node.js 18.x - node-version: "18.18" + node-version: "18" - name: Node.js 19.x - node-version: "19.9" + node-version: "19" - name: Node.js 20.x - node-version: "20.9" + node-version: "20" - name: Node.js 21.x - node-version: "21.1" + node-version: "21" - name: Node.js 22.x - node-version: "22.0" + node-version: "22" + - name: Node.js 23.x + node-version: "23" + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Node.js ${{ matrix.node-version }} + if: ${{ matrix.node-version != '0.8' }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} - - name: Install Node.js ${{ matrix.node-version }} + - name: Setup Node.js 0.8 + if: ${{ matrix.node-version == '0.8' && matrix.os == 'ubuntu-latest' }} shell: bash -eo pipefail -l {0} run: | nvm install --default ${{ matrix.node-version }} - if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then - nvm install --alias=npm 0.10 - nvm use ${{ matrix.node-version }} - if [[ "$(npm -v)" == 1.1.* ]]; then - nvm exec npm npm install -g npm@1.1 - ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" - else - sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" - fi - npm config set strict-ssl false + nvm install --alias=npm 0.10 + nvm use ${{ matrix.node-version }} + if [[ "$(npm -v)" == 1.1.* ]]; then + nvm exec npm npm install -g npm@1.1 + ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm" + else + sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" fi + npm config set strict-ssl false dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" + - name: Npm version fixes + if: ${{matrix.npm-version != ''}} + shell: bash -eo pipefail -l {0} + run: | + npm install -g ${{ matrix.npm-version }} + - name: Configure npm + shell: bash -eo pipefail -l {0} run: | - if [[ "$(npm config get package-lock)" == "true" ]]; then - npm config set package-lock false - else - npm config set shrinkwrap false - fi + npm config set package-lock false - name: Remove npm module(s) ${{ matrix.npm-rm }} if: matrix.npm-rm != '' @@ -202,10 +233,6 @@ jobs: npm test fi - - name: Lint code - if: steps.list_env.outputs.eslint != '' - run: npm run lint - - name: Collect code coverage uses: coverallsapp/github-action@master if: steps.list_env.outputs.nyc != '' diff --git a/.github/workflows/iojs.yml b/.github/workflows/iojs.yml new file mode 100644 index 0000000..fba0a20 --- /dev/null +++ b/.github/workflows/iojs.yml @@ -0,0 +1,67 @@ +name: iojs-ci + +on: + push: + branches: + - master + paths-ignore: + - '*.md' + pull_request: + paths-ignore: + - '*.md' + +concurrency: + group: "${{ github.workflow }} ✨ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: ["1.8", "2.5", "3.3"] + include: + - node-version: "1.8" + npm-i: "mocha@3.5.3 nyc@10.3.2 supertest@2.0.0" + - node-version: "2.5" + npm-i: "mocha@3.5.3 nyc@10.3.2 supertest@2.0.0" + - node-version: "3.3" + npm-i: "mocha@3.5.3 nyc@10.3.2 supertest@2.0.0" + + steps: + - uses: actions/checkout@v4 + + - name: Install iojs ${{ matrix.node-version }} + shell: bash -eo pipefail -l {0} + run: | + nvm install --default ${{ matrix.node-version }} + dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" + + - name: Configure npm + run: | + npm config set loglevel error + npm config set shrinkwrap false + + - name: Install npm module(s) ${{ matrix.npm-i }} + run: npm install --save-dev ${{ matrix.npm-i }} + if: matrix.npm-i != '' + + - name: Remove non-test dependencies + run: npm rm --silent --save-dev connect-redis + + - name: Install Node.js dependencies + run: npm install + + - name: List environment + id: list_env + shell: bash + run: | + echo "node@$(node -v)" + echo "npm@$(npm -v)" + npm -s ls ||: + (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT" + + - name: Run tests + shell: bash + run: npm run test diff --git a/README.md b/README.md index f720b0d..d77dc94 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] [![Linux Build Status][ci-image]][ci-url] -[![Windows Build][appveyor-image]][appveyor-url] [![Coverage Status][coveralls-image]][coveralls-url] Serves pages that contain directory listings for a given path. @@ -139,8 +138,6 @@ app.listen(3000) [MIT](LICENSE). The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons are created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/). -[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-index/master.svg?label=windows -[appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-index [ci-image]: https://badgen.net/github/checks/expressjs/serve-index/master?label=ci [ci-url]: https://github.com/expressjs/serve-index/actions/workflows/ci.yml [coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-index/master.svg diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a6d60ff..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,92 +0,0 @@ -environment: - matrix: - - nodejs_version: "0.8" - - nodejs_version: "0.10" - - nodejs_version: "0.12" - - nodejs_version: "1.8" - - nodejs_version: "2.5" - - nodejs_version: "3.3" - - nodejs_version: "4.9" - - nodejs_version: "5.12" - - nodejs_version: "6.17" - - nodejs_version: "7.10" - - nodejs_version: "8.17" - - nodejs_version: "9.11" - - nodejs_version: "10.24" - - nodejs_version: "11.15" - - nodejs_version: "12.22" - - nodejs_version: "13.14" - - nodejs_version: "14.16" - - nodejs_version: "15.13" -cache: - - node_modules -install: - # Install Node.js - - ps: >- - try { Install-Product node $env:nodejs_version -ErrorAction Stop } - catch { Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) } - # Configure npm - - ps: | - # Skip updating shrinkwrap / lock - npm config set shrinkwrap false - # Skip SSL validation on Node.js < 0.10 - if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) { - npm config set strict-ssl false - } - # Remove all non-test dependencies - - ps: | - # Remove coverage dependency - npm rm --silent --save-dev nyc - # Remove lint dependencies - cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | ` - sls "^eslint(-|$)" | ` - %{ npm rm --silent --save-dev $_ } - # Setup Node.js version-specific dependencies - - ps: | - # mocha for testing - # - use 2.x for Node.js < 0.10 - # - use 3.x for Node.js < 4 - # - use 5.x for Node.js < 6 - # - use 6.x for Node.js < 8 - # - use 7.x for Node.js < 10 - if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) { - npm install --silent --save-dev mocha@2.5.3 - } elseif ([int]$env:nodejs_version.split(".")[0] -lt 4) { - npm install --silent --save-dev mocha@3.5.3 - } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) { - npm install --silent --save-dev mocha@5.2.0 - } elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) { - npm install --silent --save-dev mocha@6.2.2 - } elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) { - npm install --silent --save-dev mocha@7.2.0 - } - - ps: | - # mocha for testing - # - use 1.1.0 for Node.js < 0.10 - # - use 2.0.0 for Node.js < 4 - # - use 3.4.2 for Node.js < 6 - if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) { - npm install --silent --save-dev supertest@1.1.0 - } elseif ([int]$env:nodejs_version.split(".")[0] -lt 4) { - npm install --silent --save-dev supertest@2.0.0 - } elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) { - npm install --silent --save-dev supertest@3.4.2 - } - # Update Node.js modules - - ps: | - # Prune & rebuild node_modules - if (Test-Path -Path node_modules) { - npm prune - npm rebuild - } - # Install Node.js modules - - npm install -build: off -test_script: - # Output version data - - ps: | - node --version - npm --version - # Run test script - - npm test -version: "{build}" diff --git a/package.json b/package.json index c7f520e..82f9c87 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ }, "scripts": { "lint": "eslint .", - "test": "mocha --reporter spec --bail --check-leaks test/", + "test": "mocha --reporter spec --check-leaks test/", "test-ci": "nyc --reporter=lcov --reporter=text npm test", "test-cov": "nyc --reporter=html --reporter=text npm test" }