Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta: migrate from travis-ci to Github Actions #2260

Merged
merged 1 commit into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'ecma-262'

on: [pull_request, push]

jobs:
build:
name: 'build & lint ecmarkup'
runs-on: ubuntu-latest
ljharb marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm ci'
with:
node-version: lts/*
use-npm-ci: true
- run: npm run build-master
22 changes: 22 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'ecma-262'

on:
push:
branches:
- master

jobs:
deploy:
name: 'deploy github pages'
runs-on: ubuntu-latest
if: ${{ github.repository == 'tc39/ecma262' }}

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm ci'
with:
node-version: lts/*
use-npm-ci: true
- run: npm run build-only
- run: ./scripts/auto-deploy.sh
26 changes: 26 additions & 0 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build Preview

on:
pull_request:

jobs:
build:
name: 'build PR preview'
runs-on: ubuntu-latest
outputs:
sha: ${{ github.event.pull_request.head.sha }}
pr: ${{ github.event.number }}

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm ci'
with:
node-version: lts/*
use-npm-ci: true
- run: npm run build-only
- run: node scripts/insert_snapshot_warning
- uses: actions/upload-artifact@v2
with:
name: out
path: out/
51 changes: 51 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Upload Preview

on:
workflow_run:
workflows: ["Build Preview"]
types:
- completed

jobs:
upload:
name: 'upload PR preview'
runs-on: ubuntu-latest
if: >
${{
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' &&
github.repository == 'tc39/ecma262'
}}

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm ci'
with:
node-version: lts/*
use-npm-ci: true
- name: 'Download artifact'
uses: actions/[email protected]
with:
script: |
const { owner, repo } = context.repo;
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: ${{ github.event.workflow_run.id }},
});
const { id: artifact_id } = artifacts.data.artifacts.find((artifact) => artifact.name == 'out');
const download = await github.actions.downloadArtifact({
owner,
repo,
artifact_id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{ github.workspace }}/out.zip', Buffer.from(download.data));
- run: unzip -o out.zip -d out
- run: node scripts/publish-preview
env:
CI_PREVIEW_TOKEN: ${{ secrets.CI_PREVIEW_TOKEN }}
PULL_REQUEST: ${{ github.event.workflow_run.pull_requests['0'].number }}
GITHUB_HEAD_SHA: ${{ github.event.workflow_run.head_commit.id }}
2 changes: 0 additions & 2 deletions .github/workflows/require-allow-edits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ jobs:

steps:
- uses: ljharb/require-allow-edits@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

20 changes: 13 additions & 7 deletions scripts/publish-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,41 @@ const tar = require('tar-stream');


async function go() {
const { TRAVIS_PULL_REQUEST, TRAVIS_PULL_REQUEST_SHA } = process.env;
const {
PULL_REQUEST,
GITHUB_HEAD_SHA,
GITHUB_REPOSITORY = 'tc39/ecma262',
} = process.env;

if (!TRAVIS_PULL_REQUEST) { throw new ReferenceError('Missing env var TRAVIS_PULL_REQUEST'); }
if (!TRAVIS_PULL_REQUEST_SHA) { throw new ReferenceError('Missing env var TRAVIS_PULL_REQUEST_SHA'); }
if (!PULL_REQUEST) { throw new ReferenceError('Missing env var PULL_REQUEST'); }
if (!GITHUB_HEAD_SHA) { throw new ReferenceError('Missing env var GITHUB_HEAD_SHA'); }

const dir = join(__dirname, '..', 'out');
const files = glob(join(dir, '**'), { nodir: true });

if (!files.length) { throw new ReferenceError('No preview files found to publish'); }

console.log(`Publishing preview build of PR ${TRAVIS_PULL_REQUEST} (SHA ${TRAVIS_PULL_REQUEST_SHA})`);
console.log(`Publishing preview build of PR ${PULL_REQUEST} (SHA ${GITHUB_HEAD_SHA})`);

const compressed = await compress(files, dir);
console.log(`Packed to ${compressed.length / 1000}kB`);

const data = {
pr: TRAVIS_PULL_REQUEST,
sha: TRAVIS_PULL_REQUEST_SHA,
pr: PULL_REQUEST,
sha: GITHUB_HEAD_SHA,
compressed,
};

const url = 'https://ci.tc39.es/preview/tc39/ecma262';
const [user, repo] = GITHUB_REPOSITORY.split('/');
const url = `https://ci.tc39.es/preview/${user}/${repo}`;

const payloadSize = JSON.stringify(data).length;
console.log(`Payload size: ${payloadSize / 1000}kB`);
if (payloadSize >= 1000 * 1000 * 6) {
throw Error('Payloads must be under 6MB');
}

console.log(`URL posted to: ${url}`);
await tiny.post({ url, data });
console.log('Sent to preview!')
}
Expand Down