Skip to content

Commit

Permalink
chore: setup gitlab pipeline (#168)
Browse files Browse the repository at this point in the history
* chore: setup gitlab pipeline
* improv: delete deprecated github release workflow
* docs: update docs related to releasing
  • Loading branch information
jtmalinowski authored May 21, 2021
1 parent 10aef26 commit ab6caf5
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 162 deletions.
114 changes: 0 additions & 114 deletions .github/workflows/release.yml

This file was deleted.

85 changes: 85 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
default:
image: 'cimg/node:lts-browsers'

cache:
key:
files:
- package-lock.json
paths:
- .npm/
- node_modules/

# tell npm to store cache in .npm so it can be cached by Gitlab
before_script:
- npm ci --cache .npm --prefer-offline

stages:
- setup
- build
- test
- release

npm_install:
stage: setup
script:
- npm install

lint:
stage: build
script:
- npm run lint
- npm run lint:markdown

build:
stage: build
only:
- /^[^v].*/
artifacts:
paths:
- dist/
script:
- npm run compile

build_artifacts:
stage: build
only:
- /^v[0-9]+\..*/
artifacts:
paths:
- dist/artifacts/
script:
- npm run compile
- npm pack

# complete artifacts & checksums
- mv splunk-otel-web-${CI_COMMIT_REF_NAME:1}.tgz dist/artifacts/
- shasum -a 256 dist/artifacts/* > dist/artifacts/checksums.txt

unit_test:
stage: test
script:
- npm run test:unit:ci

release_production:
artifacts:
paths:
- dist/artifacts/
stage: release
only:
- /^v[0-9]+\..*/
script:
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
- sudo apt-add-repository https://cli.github.com/packages
- sudo apt update
- sudo apt install gh

# release to NPM
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- npm publish ./dist/artifacts/splunk-otel-web-${CI_COMMIT_REF_NAME:1}.tgz
- rm -f ~/.npmrc

# release in Github
- gh release create v${CI_COMMIT_REF_NAME:1} ./dist/artifacts/* --target $CI_COMMIT_SHA --repo $GITHUB_REPOSITORY

# release to CDN
- node scripts/release-cdn.mjs
39 changes: 3 additions & 36 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
# Building, testing and contributing to splunk-browser-otel-js
## Building, preamble
This repo makes use of git submodules to pull in the latest otel-js and otel-js-contrib code. In time, we may move to only using
published versions. Meanwhile, do not modify anything in the deps/ directory once you've updated the submodules. We want to make
direct contributions to otel upstream.
## Building

```bash
$ git submodule update --init --recursive # one-time
$ git submodule update --recursive # every time you update this repo
```

## Building, for real
Build as so:

```bash
$ git submodule update
$ npm install
$ npm run dist
$ npm run lint (optional)
$ npm test (optional)
npm install
npm run compile
```

## Functional tests
Expand Down Expand Up @@ -45,25 +31,6 @@ Requires the code below to be run once, to enable running integration tests in S
$ /usr/bin/safaridriver --enable
```

## Releasing
1. Prepare the release commit on `main`
1. Update the version in `package.json`
1. `npm i` to update the version in `package-lock.json`
1. Update the changelog by creating a section for the new version, and moving all unreleased entries to it
1. Commit as `chore: prepare release <version>`
1. `git push origin main` to publish
1. `git tag v<version>` - please don't forget the "v"
1. `git push origin v<version>` to publish the version tag, this starts the Github workflow, which will:
1. create a Github Release
1. publish to NPM
1. Navigate to <https://github.com/signalfx/rum-browser-js/releases/> and find the release you just created
1. Update the changelog or link to the right section in README.
1. run `npm run release:cdn` and verify that the plan is correct
1. run `npm run release:cdn:wet`
1. this script updates release contents and will ask you to verify them (URL will be provided)
1. update the versions in `integration-tests/tests/cdn/index.ejs` and `integration-tests/tests/cdn/index.spec.js`
1. verify that CDN works by running `npm run test:integration:local:chrome`

## Community Contributions

If you are not a Splunk employee and would like to contribute code to this project, please read and fill out the
Expand Down
4 changes: 2 additions & 2 deletions performance-tests/devServer/splunkRumProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ async function handleSplunkRumRequest(app) {

function generateSplunkRumTags () {
const options = {
beaconUrl: `/api/v2/spans`,
beaconUrl: `/api/v2/spans`,
app: 'splunk-otel-js-dummy-app',
debug: false,
};

return render(SPLUNK_RUM_TAGS_TEMPLATE, {
file: '/dist/browser/splunk-otel-web.js',
file: '/dist/artifacts/splunk-otel-web.js',
options: JSON.stringify(options),
});
}
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default [
{
input: 'src/indexBrowser.ts',
output: {
file: 'dist/browser/splunk-otel-web.js',
file: 'dist/artifacts/splunk-otel-web.js',
format: 'iife',
name: 'SplunkRum',
sourcemap: true,
Expand All @@ -35,7 +35,7 @@ export default [
{
input: 'src/indexBrowser.ts',
output: {
file: 'dist/browser/splunk-otel-web-legacy.js',
file: 'dist/artifacts/splunk-otel-web-legacy.js',
format: 'iife',
name: 'SplunkRum',
sourcemap: true,
Expand Down
6 changes: 3 additions & 3 deletions utils/devServer/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<html>
<head>
<script src="/dist/browser/splunk-otel-web.js"></script>
<script src="/dist/artifacts/splunk-otel-web.js"></script>
<script>
window.SplunkRum && window.SplunkRum.init({
beaconUrl: '/api/v2/spans',
window.SplunkRum && window.SplunkRum.init({
beaconUrl: '/api/v2/spans',
app: 'splunk-otel-js-dummy-app',
debug: true
});
Expand Down
10 changes: 5 additions & 5 deletions utils/devServer/templateProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const INJECT_TEMPLATE = `<script src="<%= file -%>" crossorigin="anonymous"></sc
<script>
<%if (noInit) { %>
window.SplunkRumOptions = <%- options -%>;
<% } else { %>
<% } else { %>
window.SplunkRum && window.SplunkRum.init(<%- options -%>);
<% } %>
Expand Down Expand Up @@ -78,18 +78,18 @@ const INJECT_TEMPLATE = `<script src="<%= file -%>" crossorigin="anonymous"></sc
`;

exports.registerTemplateProvider = ({app, addHeaders, enableHttps}) => {
app.use(function(req, res, next) {
app.use(function(req, res, next) {
const filepath = path.resolve(__dirname, '..', '..', 'integration-tests', 'tests', req.path.substring(1));
if (fs.existsSync(filepath)) {
const beaconUrl = new URL(`${enableHttps ? 'https' : 'http'}://${req.headers.host}/api/v2/spans`);
if (req.query.beaconPort) {
beaconUrl.port = req.query.beaconPort;
}

let defaultFile = '/dist/browser/splunk-otel-web.js';
let defaultFile = '/dist/artifacts/splunk-otel-web.js';
const browser = req.header('User-Agent')
if (browser && browser.includes('Trident')) {
defaultFile = '/dist/browser/splunk-otel-web-legacy.js';
defaultFile = '/dist/artifacts/splunk-otel-web-legacy.js';
}

addHeaders(res);
Expand Down Expand Up @@ -124,7 +124,7 @@ exports.registerTemplateProvider = ({app, addHeaders, enableHttps}) => {
});
},
});
}
}
return next();
});
};

0 comments on commit ab6caf5

Please sign in to comment.