Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
chore: revert peer api check removal
  • Loading branch information
dyladan committed Apr 15, 2022
commit e6d2855d1714720044f3e586c2c1df78330adb44
26 changes: 26 additions & 0 deletions .github/workflows/peer-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Ensure API Peer Dependency

on:
push:
branches:
- main
pull_request:

jobs:
peer-api-check:
runs-on: ubuntu-latest
container:
image: node:14
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install lerna
run: npm install -g lerna

- name: Install semver
run: npm install semver

- name: Check API dependency semantics
working-directory: packages
run: lerna exec --ignore propagation-validation-server --ignore @opentelemetry/api-metrics --ignore propagation-validation-server --ignore @opentelemetry/selenium-tests "node $(pwd)/scripts/peer-api-check.js"
37 changes: 37 additions & 0 deletions scripts/peer-api-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const fs = require('fs');
const os = require('os');
const path = require('path');
const semver = require('semver');

const appRoot = process.cwd();

const packageJsonUrl = path.resolve(`${appRoot}/package.json`);
const pjson = require(packageJsonUrl);

if (pjson.dependencies && pjson.dependencies["@opentelemetry/api"])
throw new Error(`Package ${pjson.name} depends on API but it should be a peer dependency`);

const peerVersion = pjson.peerDependencies && pjson.peerDependencies["@opentelemetry/api"]
const devVersion = pjson.devDependencies && pjson.devDependencies["@opentelemetry/api"]
if (peerVersion) {
if (!semver.subset(devVersion, peerVersion)) {
throw new Error(`Package ${pjson.name} depends on peer API version ${peerVersion} but version ${devVersion} in development`);
}
console.log(`${pjson.name} OK`);
}