Skip to content

Commit

Permalink
Merge branch 'master' into feat/9493/improve-auth-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jNullj committed Jun 8, 2024
2 parents 94a479a + 0360ba3 commit ee75674
Show file tree
Hide file tree
Showing 116 changed files with 3,306 additions and 2,313 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ runs:
using: 'composite'
steps:
- name: Install Node JS ${{ inputs.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

Expand Down
10 changes: 9 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ updates:

# GH actions
- package-ecosystem: 'github-actions'
directory: '/'
# all composite actions must be individually listed here
# https://github.com/dependabot/dependabot-core/issues/6704
directories:
- '/'
- '/.github/actions/core-tests'
- '/.github/actions/integration-tests'
- '/.github/actions/package-tests'
- '/.github/actions/service-tests'
- '/.github/actions/setup'
schedule:
interval: weekly
open-pull-requests-limit: 99
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/deploy-review-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if ! flyctl status --app "$app"; then
fi

# Deploy
flyctl deploy --app "$app" --region "$region"
flyctl deploy --app "$app" --regions "$region"
flyctl scale count 1 --app "$app" --yes

# Post a comment on the PR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration@node 21
name: Integration@node 22
on:
pull_request:
types: [opened, reopened, synchronize]
Expand All @@ -8,7 +8,7 @@ on:
- 'dependabot/**'

jobs:
test-integration-21:
test-integration-22:
runs-on: ubuntu-latest
env:
PAT_EXISTS: ${{ secrets.GH_PAT != '' }}
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
with:
node-version: 21
node-version: 22
env:
NPM_CONFIG_ENGINE_STRICT: 'false'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Main@node 21
name: Main@node 22
on:
pull_request:
types: [opened, reopened, synchronize]
Expand All @@ -8,7 +8,7 @@ on:
- 'dependabot/**'

jobs:
test-main-21:
test-main-22:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
with:
node-version: 21
node-version: 22
env:
NPM_CONFIG_ENGINE_STRICT: 'false'

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-package-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- node: '16'
- node: '18'
- node: '20'
- node: '22'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-package-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- node: '20'
npm: '^10'
engine-strict: 'true'
- node: '22'
npm: '^10'
engine-strict: 'false'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Services@node 21
name: Services@node 22
on:
pull_request:
types: [opened, edited, reopened, synchronize]
Expand All @@ -7,7 +7,7 @@ on:
- 'gh-readonly-queue/**'

jobs:
test-services-21:
test-services-22:
runs-on: ubuntu-latest

steps:
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Setup
uses: ./.github/actions/setup
with:
node-version: 21
node-version: 22
env:
NPM_CONFIG_ENGINE_STRICT: 'false'

Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@ Note: this changelog is for the shields.io server. The changelog for the badge-m

---

## server-2024-06-01

- Remove namedLogo from defaultBadgeData of non-social badges [#10195](https://github.com/badges/shields/issues/10195)
- Update number of badges served each month [#10197](https://github.com/badges/shields/issues/10197)
- Delete old deprecated services [#10196](https://github.com/badges/shields/issues/10196)
- handle [BitbucketPipelines] responses with missing result key [#10163](https://github.com/badges/shields/issues/10163)
- Update description of GitHub commit status badge [#10198](https://github.com/badges/shields/issues/10198)
- chore: fix spelling of GitHub in badge descriptions [#10199](https://github.com/badges/shields/issues/10199)
- Add [GithubCheckRuns] service [#7759](https://github.com/badges/shields/issues/7759)
- feat: add Revolt badge [#10093](https://github.com/badges/shields/issues/10093)
- ensure color is string before calling toLowerCase() [#10129](https://github.com/badges/shields/issues/10129)
- instruct dependabot to monitor composite actions [#10139](https://github.com/badges/shields/issues/10139)
- run tests on node 22 [#10127](https://github.com/badges/shields/issues/10127)
- tweaks to libraries.io token pooling code [#10074](https://github.com/badges/shields/issues/10074)
- fix [pypi] status badge when package has no 'Development Status' classifier [#10107](https://github.com/badges/shields/issues/10107)
- clarify yml paths in server-secrets docs [#10106](https://github.com/badges/shields/issues/10106)
- Update region flag name in flyctl deploy command [#10134](https://github.com/badges/shields/issues/10134)
- Dependency updates

## server-2024-05-01

- [Hexpm] Fix badges for pre-release only versions [#10112](https://github.com/badges/shields/issues/10112)
- feat(logos): support auto-sizing mode [#9191](https://github.com/badges/shields/issues/9191) [#10110](https://github.com/badges/shields/issues/10110) [#10125](https://github.com/badges/shields/issues/10125)
- support setting pypiBaseUrl by environment variables and queryParameters; affects [pypi] [#10044](https://github.com/badges/shields/issues/10044)
- Add 0BSD license to licenseTypes and [PypiLicense] [#10092](https://github.com/badges/shields/issues/10092)
- Update Mastodon profile URL [#10082](https://github.com/badges/shields/issues/10082)
- [GitHubGoMod] Ignore comment after version (fixes #10079) [#10080](https://github.com/badges/shields/issues/10080)
- Perf: Librariesio repo dependencies [#10062](https://github.com/badges/shields/issues/10062)
- [Chocolatey Nuget] Fix "not found" error for chocolatey badge [#10060](https://github.com/badges/shields/issues/10060)
- Dependency updates

## server-2024-04-01

- improve performance of [GithubLastCommit] [GitlabLastCommit] [GiteaLastCommit] [#10046](https://github.com/badges/shields/issues/10046)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ and legible badges in SVG and raster format, which can easily be included in
GitHub readmes or any other web page. The service supports dozens of
continuous integration services, package registries, distributions, app
stores, social networks, code coverage services, and code analysis services.
Every month it serves over 870 million images and is used by some of the
Every month it serves over 1.6 billion images and is used by some of the
world's most popular open-source projects, [VS Code][vscode], [Vue.js][vue]
and [Bootstrap][bootstrap] to name a few.

Expand Down Expand Up @@ -99,7 +99,7 @@ If you intend on reporting or contributing a fix related to security vulnerabili
## Development

1. Install Node 20 or later. You can use the [package manager][] of your choice.
Tests need to pass in Node 20 and 21.
Tests need to pass in Node 20 and 22.
2. Clone this repository.
3. Run `npm ci` to install the dependencies.
4. Run `npm start` to start the badge server and the frontend dev server.
Expand Down
2 changes: 1 addition & 1 deletion badge-maker/lib/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function normalizeColor(color) {
} else if (color in aliases) {
return aliases[color]
} else if (isHexColor(color)) {
return `#${color.toLowerCase()}`
return `#${color.toString().toLowerCase()}`
} else if (isCSSColor(color)) {
return color.toLowerCase()
} else {
Expand Down
2 changes: 2 additions & 0 deletions badge-maker/lib/color.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ test(normalizeColor, () => {
given('blue').expect('blue')
given('4c1').expect('#4c1')
given('f00f00').expect('#f00f00')
given('111111').expect('#111111')
given(111111).expect('#111111')
given('ABC123').expect('#abc123')
given('#ccc').expect('#ccc')
given('#fffe').expect('#fffe')
Expand Down
5 changes: 5 additions & 0 deletions badge-maker/lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const DEFAULT_LOGO_HEIGHT = 14

module.exports = {
DEFAULT_LOGO_HEIGHT,
}
5 changes: 4 additions & 1 deletion badge-maker/lib/make-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { normalizeColor, toSvgColor } = require('./color')
const badgeRenderers = require('./badge-renderers')
const { stripXmlWhitespace } = require('./xml')
const { DEFAULT_LOGO_HEIGHT } = require('./constants')

/*
note: makeBadge() is fairly thinly wrapped so if we are making changes here
Expand All @@ -17,6 +18,7 @@ module.exports = function makeBadge({
labelColor,
logo,
logoPosition,
logoSize,
logoWidth,
links = ['', ''],
}) {
Expand Down Expand Up @@ -45,7 +47,7 @@ module.exports = function makeBadge({
throw new Error(`Unknown badge style: '${style}'`)
}

logoWidth = +logoWidth || (logo ? 14 : 0)
logoWidth = +logoWidth || (logo ? DEFAULT_LOGO_HEIGHT : 0)

return stripXmlWhitespace(
render({
Expand All @@ -55,6 +57,7 @@ module.exports = function makeBadge({
logo,
logoPosition,
logoWidth,
logoSize,
logoPadding: logo && label.length ? 3 : 0,
color: toSvgColor(color),
labelColor: toSvgColor(labelColor),
Expand Down
2 changes: 2 additions & 0 deletions config/custom-environment-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public:
authorizedOrigins: 'NPM_ORIGINS'
obs:
authorizedOrigins: 'OBS_ORIGINS'
pypi:
baseUri: 'PYPI_URL'
sonar:
authorizedOrigins: 'SONAR_ORIGINS'
teamcity:
Expand Down
2 changes: 2 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public:
restApiVersion: '2022-11-28'
obs:
authorizedOrigins: 'https://api.opensuse.org'
pypi:
baseUri: 'https://pypi.org'
weblate:
authorizedOrigins: 'https://hosted.weblate.org'
trace: false
Expand Down
1 change: 1 addition & 0 deletions core/base-service/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ describe('BaseService', function () {
namedLogo: undefined,
logo: undefined,
logoWidth: undefined,
logoSize: undefined,
logoPosition: undefined,
links: [],
labelColor: undefined,
Expand Down
22 changes: 20 additions & 2 deletions core/base-service/coalesce-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
decodeDataUrlFromQueryParam,
prepareNamedLogo,
} from '../../lib/logos.js'
import { svg2base64 } from '../../lib/svg-helpers.js'
import { svg2base64, getIconSize } from '../../lib/svg-helpers.js'
import { DEFAULT_LOGO_HEIGHT } from '../../badge-maker/lib/constants.js'
import coalesce from './coalesce.js'
import toArray from './to-array.js'

Expand Down Expand Up @@ -56,6 +57,7 @@ export default function coalesceBadge(
let {
logoWidth: overrideLogoWidth,
logoPosition: overrideLogoPosition,
logoSize: overrideLogoSize,
color: overrideColor,
labelColor: overrideLabelColor,
} = overrides
Expand Down Expand Up @@ -87,6 +89,7 @@ export default function coalesceBadge(
logoSvg: serviceLogoSvg,
namedLogo: serviceNamedLogo,
logoColor: serviceLogoColor,
logoSize: serviceLogoSize,
logoWidth: serviceLogoWidth,
logoPosition: serviceLogoPosition,
link: serviceLink,
Expand Down Expand Up @@ -119,7 +122,12 @@ export default function coalesceBadge(
style = 'flat'
}

let namedLogo, namedLogoColor, logoWidth, logoPosition, logoSvgBase64
let namedLogo,
namedLogoColor,
logoSize,
logoWidth,
logoPosition,
logoSvgBase64
if (overrideLogo) {
// `?logo=` could be a named logo or encoded svg.
const overrideLogoSvgBase64 = decodeDataUrlFromQueryParam(overrideLogo)
Expand All @@ -133,6 +141,7 @@ export default function coalesceBadge(
}
// If the logo has been overridden it does not make sense to inherit the
// original width or position.
logoSize = overrideLogoSize
logoWidth = overrideLogoWidth
logoPosition = overrideLogoPosition
} else {
Expand All @@ -145,13 +154,21 @@ export default function coalesceBadge(
)
namedLogoColor = coalesce(overrideLogoColor, serviceLogoColor)
}
logoSize = coalesce(overrideLogoSize, serviceLogoSize)
logoWidth = coalesce(overrideLogoWidth, serviceLogoWidth)
logoPosition = coalesce(overrideLogoPosition, serviceLogoPosition)
}
if (namedLogo) {
const iconSize = getIconSize(String(namedLogo).toLowerCase())

if (!logoWidth && iconSize && logoSize === 'auto') {
logoWidth = (iconSize.width / iconSize.height) * DEFAULT_LOGO_HEIGHT
}

logoSvgBase64 = prepareNamedLogo({
name: namedLogo,
color: namedLogoColor,
size: logoSize,
style,
})
}
Expand Down Expand Up @@ -179,6 +196,7 @@ export default function coalesceBadge(
logo: logoSvgBase64,
logoWidth,
logoPosition,
logoSize,
links: toArray(overrideLink || serviceLink),
cacheLengthSeconds: coalesce(serviceCacheSeconds, defaultCacheSeconds),
}
Expand Down
14 changes: 14 additions & 0 deletions core/base-service/coalesce-badge.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ describe('coalesceBadge', function () {
})
})

describe('Logo size', function () {
it('overrides the logoSize', function () {
expect(coalesceBadge({ logoSize: 'auto' }, {}, {})).to.include({
logoSize: 'auto',
})
})

it('applies the logo size', function () {
expect(
coalesceBadge({}, { namedLogo: 'npm', logoSize: 'auto' }, {}),
).to.include({ logoSize: 'auto' })
})
})

describe('Logo width', function () {
it('overrides the logoWidth', function () {
expect(coalesceBadge({ logoWidth: 20 }, {}, {})).to.include({
Expand Down
2 changes: 1 addition & 1 deletion core/base-service/coalesce.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import coalesce from './coalesce.js'
// https://github.com/royriojas/coalescy for these tests!

describe('coalesce', function () {
test(coalesce, function () {
test(coalesce, () => {
given().expect(undefined)
given(null, []).expect([])
given(null, [], {}).expect([])
Expand Down
1 change: 1 addition & 0 deletions core/base-service/legacy-request-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const globalQueryParams = new Set([
'logo',
'logoColor',
'logoPosition',
'logoSize',
'logoWidth',
'link',
'colorA',
Expand Down
Loading

0 comments on commit ee75674

Please sign in to comment.