Skip to content

Commit

Permalink
Replace Travis CI with Github Actions (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoninbas authored Mar 14, 2022
1 parent bd889ab commit 04f8e83
Show file tree
Hide file tree
Showing 9 changed files with 194 additions and 125 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/any-branch-uploads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Any branch uploads

on:
push:
branches:
- '**'

jobs:
any-branch-uploads:
if: ${{ github.repository == 'p4lang/p4runtime' }}
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Build spec
run: |
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
ls docs/v1/build
- name: Upload spec to S3 if needed
uses: jakejarvis/[email protected]
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: 'p4runtime'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-2'
SOURCE_DIR: 'docs/v1/build'
DEST_DIR: ci/${{ github.ref_name }} # only runs for push events
22 changes: 22 additions & 0 deletions .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Check generated code

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check-codegen:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Compile protobufs
run: |
docker build -t p4runtime-ci -f codegen/Dockerfile .
docker run -t p4runtime-ci /p4runtime/codegen/compile_protos.sh /tmp
- name: Check codegen
run: |
./CI/check_codegen.sh
47 changes: 47 additions & 0 deletions .github/workflows/main-branch-uploads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Main branch uploads

on:
push:
branches:
- main

jobs:
main-branch-uploads:
if: ${{ github.repository == 'p4lang/p4runtime' }}
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
with:
# fetch all history for all branches and tags
fetch-depth: 0
- name: Build spec
run: |
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
ls docs/v1/build
- name: Upload spec to S3
uses: jakejarvis/[email protected]
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: 'p4runtime'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-2'
SOURCE_DIR: 'docs/v1/build'
DEST_DIR: docs/main
- name: Prepare spec for upload to gh-pages
run: |
git checkout gh-pages
mkdir -p spec
rm -rf spec/main
cp -r docs/v1/build spec/main
- name: Upload spec to gh-pages
uses: EndBug/add-and-commit@v9
with:
add: 'spec'
author_name: 'P4Runtime CI'
author_email: '[email protected]'
default_author: github_actions
message: 'Publish spec from Github Actions'
commit: '--amend'
push: 'origin gh-pages --force'
27 changes: 27 additions & 0 deletions .github/workflows/spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build spec

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
madoko-lint:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Run linter
run: |
./tools/madokolint.py docs/v1/P4Runtime-Spec.mdk
build-spec:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Build spec
run: |
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
ls docs/v1/build
62 changes: 62 additions & 0 deletions .github/workflows/tag-uploads.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Tag uploads

on:
push:
tags:
- v*

jobs:
tag-uploads:
if: ${{ github.repository == 'p4lang/p4runtime' }}
runs-on: [ubuntu-latest]
env:
TAG: ${{ github.ref }}
steps:
- uses: actions/checkout@v3
with:
# fetch all history for all branches and tags
fetch-depth: 0
- name: Build spec
run: |
docker run -v `pwd`/docs/v1:/usr/src/p4-spec p4lang/p4rt-madoko:latest make
ls docs/v1/build
- name: Upload spec to S3
uses: jakejarvis/[email protected]
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: 'p4runtime'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-west-2'
SOURCE_DIR: 'docs/v1/build'
DEST_DIR: docs/${{ github.ref }}
- name: Prepare spec for upload to gh-pages
run: |
git checkout gh-pages
mkdir -p spec
rm -rf spec/$TAG
cp -r docs/v1/build spec/$TAG
- name: Upload spec to gh-pages
uses: EndBug/add-and-commit@v9
with:
add: 'spec'
author_name: 'P4Runtime CI'
author_email: '[email protected]'
default_author: github_actions
message: 'Publish spec from Github Actions'
commit: '--amend'
push: 'origin gh-pages --force'

publish-to-pypi:
name: Publish a Python distribution to PyPI
if: ${{ github.repository == 'p4lang/p4runtime' }}
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: py/
skip_existing: true
83 changes: 0 additions & 83 deletions .travis.yml

This file was deleted.

33 changes: 0 additions & 33 deletions CI/deploy.sh

This file was deleted.

11 changes: 5 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,16 @@ change the object's aspect ratio.)

## CI upload of built documents

Travis takes care of uploading the built HTML version of the spec to Github. The
latest working draft (main branch) can be found
Github Actions take care of uploading the built HTML version of the spec to
Github. The latest working draft (main branch) can be found
[here](https://p4.org/p4runtime/spec/main/P4Runtime-Spec.html).

Additionally, you can access the HTML & PDF versions of the spec for any given
branch of this repository by using the following URLs:
* `https://s3-us-west-2.amazonaws.com/p4runtime/travis/<your_branch_name>/P4Runtime-Spec.html`
* `https://s3-us-west-2.amazonaws.com/p4runtime/ci/<your_branch_name>/P4Runtime-Spec.html`
for the **HTML** version
* `https://s3-us-west-2.amazonaws.com/p4runtime/travis/<your_branch_name>/P4Runtime-Spec.pdf`
* `https://s3-us-west-2.amazonaws.com/p4runtime/ci/<your_branch_name>/P4Runtime-Spec.pdf`
for the **PDF** version

Unfortunately, because of how Travis encrypts environment variables (which are
required to upload documents to S3), this does not work for branches in forked
Unfortunately, for security reasons, this does not work for branches in forked
repositories, even for opened pull requests.
6 changes: 3 additions & 3 deletions docs/tools/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Dockerfile.madoko is used to build a Docker image which we use to render the
P4Runtime specification (HTML & PDF) in Travis CI. The image can also be used
locally to build the specification without having to worry about installing all
the dependencies yourself.
P4Runtime specification (HTML & PDF) in CI. The image can also be used locally
to build the specification without having to worry about installing all the
dependencies yourself.

Only maintainers of this repository need to build the Docker image when a new
image needs to be pushed to dockerhub. Contributors to the specification can
Expand Down

0 comments on commit 04f8e83

Please sign in to comment.