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

ci: Start using github actions for CI #235

Merged
merged 53 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
7d274cc
maint(ci): Start using github actions for CI
Jun 10, 2020
307e226
Enable workspaces, all features and locked Cargo.lock file
Jun 10, 2020
ec5cfa8
Add newline at end of file...
Jun 10, 2020
5c2de66
Use our clippy flags
Jun 12, 2020
28ec04f
Limit push build to only build for pushes to master
Jun 15, 2020
b8987e1
Start testing caching
Jun 15, 2020
62aeebe
fix typo
Jun 15, 2020
45f5b8f
Same typo
Jun 15, 2020
42b372f
Also cache build stuff
Jun 15, 2020
6bf746b
Try passing caches between jobs using artifacts
Jun 15, 2020
c7a85a4
typo
Jun 15, 2020
f4246c7
Attempt to find where rust actually lives
Jun 15, 2020
f094376
Abandon artifacts, might as well wait for Godot
Jun 15, 2020
ffbce5f
Remove unused dependency
Jun 15, 2020
35c8161
run check, not build
Jun 15, 2020
b39509b
Maybe we don't need to cache the downloaded stuff
Jun 15, 2020
2e82d0c
Change for change's sake, I need to see caches working
Jun 15, 2020
461a70c
We do need to cache downloads
Jun 15, 2020
78f0f7e
Also cache git downloads
Jun 15, 2020
e7633be
Attempt to run the integration tests as well
Aug 3, 2020
8d42e5b
Add python linting
Aug 3, 2020
5b75aa2
Fix cargo fmt invocation
Aug 3, 2020
1c31851
Split tests in unit and integration tests for more parallelisation
Aug 3, 2020
c3ecc44
Rename to ci, no longer just rust-specific
Aug 3, 2020
a9abbf7
Also rename the workfolow instead of only the file
Aug 3, 2020
c2c818f
Use unique cache keys for both tests suites
Aug 3, 2020
cc75a77
Build the docs
Aug 3, 2020
a2da557
Spell ubuntu correctly...
Aug 3, 2020
6383459
Do not allow skipping tests with credentials on CI
Aug 10, 2020
a31286d
Configure the secrets as env vars
Aug 11, 2020
d4b4681
Update some stuff for the sake of it
Oct 1, 2020
e20f55b
Give things names again
Oct 1, 2020
d5056bc
Put some upload stuff in there
Oct 1, 2020
bd33e88
Merge branch 'master' into maint/github-actions
Oct 1, 2020
1f428b9
Update .github/workflows/ci.yml
Oct 2, 2020
4295645
Update .github/workflows/ci.yml
Oct 2, 2020
cba53cc
Add release workflow to upload docs
Oct 2, 2020
ce0e9e6
Use the job_id for cache key
Oct 2, 2020
50f1135
Correct syntax
Oct 2, 2020
82b7b14
Less confusing name
Oct 2, 2020
561bb8b
Use zeus directly
Oct 2, 2020
b3d10bb
Use npx instead of yarn
Oct 2, 2020
52dbb17
Do not name the upload
Oct 2, 2020
2eb130e
Actually zip up the docs
Oct 2, 2020
9ede8d1
Remove travis config
Oct 2, 2020
eafab8a
Remove test setup
Oct 2, 2020
a090f8c
More suitable name
Oct 2, 2020
6045095
Do not require binaries for releases
Oct 2, 2020
75c176f
Build binaries again
Oct 5, 2020
49dc5ef
Do not use makefile for docs building
Oct 5, 2020
60088f3
Correct release binary location
Oct 5, 2020
bc5771b
Quotes are hard
Oct 5, 2020
f11e867
Remove temp test config
Oct 5, 2020
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
2 changes: 0 additions & 2 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ targets:

requireNames:
- /^gh-pages.zip$/
- /^symbolicator-Linux-x86_64$/
- /^symbolicator-Linux-x86_64-debug.zip$/
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Release build

on:
push:
branches:
- release/**

jobs:
docs:
name: Upload docs
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup Virtualenv
run: pip install virtualenv

- name: Build Docs
run: |
make docs
cd site && zip -r gh-pages .

- name: Setup node
uses: actions/setup-node@v1

- name: Upload to Zeus
env:
ZEUS_HOOK_BASE: ${{ secrets.ZEUS_HOOK_BASE }}
run: |
npm install -D @zeus-ci/cli
npx zeus job update -b ${{ github.run_id }} -j ${{ github.job }} -r ${{ github.sha }}
npx zeus upload -b ${{ github.run_id }} -j ${{ github.job }} -t "application/zip+docs" site/gh-pages.zip
npx zeus job update --status=passed -b ${{ github.run_id }} -j ${{ github.job }} -r ${{ github.sha }}
137 changes: 137 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: CI

on:
push:
branches:
- master
- release/**

pull_request:

jobs:
lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install python
uses: actions/setup-python@v2
with:
python-version: 3.8
flub marked this conversation as resolved.
Show resolved Hide resolved

- name: Install python dependencies
run: pip install --upgrade black flake8

- name: Run Black
run: black --check tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: should we use this directly instead of makefile for symbolic as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're going with explicit commands now, I would say yes. The makefile becomes an interface for the developer, and CI has it's own (equivalent or equal) commands.


- name: Run Flake8
run: flake8 tests

- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustfmt, clippy
override: true

- name: Cache rust cargo artifacts
uses: swatinem/rust-cache@v1
with:
key: ${{ github.job }}

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run clipppy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --workspace --tests --examples -- -D clippy::all

unit-test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Cache rust cargo artifacts
uses: swatinem/rust-cache@v1
with:
key: ${{ github.job }}

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace --all-features --locked

integration-test:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install rust stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Cache rust cargo artifacts
uses: swatinem/rust-cache@v1
with:
key: ${{ github.job }}

- name: Build rust
run: cargo build --locked

- name: Install python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup python environment
run: pip install --upgrade pytest pytest-localserver requests pytest-xdist pytest-icdiff boto3

- name: Integration tests
env:
SENTRY_SYMBOLICATOR_GCS_CLIENT_EMAIL: ${{ secrets.SENTRY_SYMBOLICATOR_GCS_CLIENT_EMAIL }}
SENTRY_SYMBOLICATOR_GCS_PRIVATE_KEY: ${{ secrets.SENTRY_SYMBOLICATOR_GCS_PRIVATE_KEY }}
SENTRY_SYMBOLICATOR_TEST_AWS_ACCESS_KEY_ID: ${{ secrets.SENTRY_SYMBOLICATOR_TEST_AWS_ACCESS_KEY_ID }}
SENTRY_SYMBOLICATOR_TEST_AWS_SECRET_ACCESS_KEY: ${{ secrets.SENTRY_SYMBOLICATOR_TEST_AWS_SECRET_ACCESS_KEY }}
run: pytest --ci -n12 -vv tests/integration

docs:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup Virtualenv
run: pip install virtualenv

- name: Build Docs
run: make docs
flub marked this conversation as resolved.
Show resolved Hide resolved
56 changes: 0 additions & 56 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ test: test-rust test-integration
.PHONY: test

test-rust:
cargo test --all --all-features --locked
cargo test --workspace --all-features --locked
.PHONY: test-rust

test-integration: .venv/bin/python
.venv/bin/pip install -U pytest pytest-localserver requests pytest-xdist pytest-icdiff boto3
cargo build --locked
@.venv/bin/pytest tests -n12 -vv
@.venv/bin/pytest $(CI_ARGS) tests/integration -n12 -vv
.PHONY: test-integration

# Documentation
Expand Down Expand Up @@ -86,7 +86,7 @@ lint-python: .venv/bin/python

lint-rust:
@rustup component add clippy --toolchain stable 2> /dev/null
cargo +stable clippy --all-features --all --tests --examples -- -D clippy::all
cargo +stable clippy --all-features --workspace --tests --examples -- -D clippy::all
.PHONY: lint-rust

# Formatting
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]
addopts = -ra --tb=native --durations 5 -p no:warnings
testpaths = tests
testpaths = tests/integration
markers =
extra_failure_checks: Marker which can add additional failure checks to
a test. It accepts the keyword argument `checks` which should be a
Expand Down
26 changes: 22 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
session = requests.session()


@pytest.hookimpl
def pytest_addoption(parser):
parser.addoption(
"--ci",
action="store_true",
help="Indicate the tests are being run on CI, "
"this e.g. prefers to fail tests instead of skipping them.",
)


@pytest.hookimpl
def pytest_sessionstart(session):
no_fds_soft, no_fds_hard = resource.getrlimit(resource.RLIMIT_NOFILE)
Expand Down Expand Up @@ -271,9 +281,13 @@ def fail_on_errors():


@pytest.fixture
def s3():
def s3(pytestconfig):
if not AWS_ACCESS_KEY_ID or not AWS_SECRET_ACCESS_KEY:
pytest.skip("No AWS credentials")
msg = "No AWS credentials"
if pytestconfig.getoption("ci"):
pytest.fail(msg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory this kind of stuff could be monitored by measuring coverage on the testsuite itself. Then you can find tests that are improperly skipped or not discovered at all for whatever reason.

In practice it's much harder to set up.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that could work if you have a 100% test coverage enforced. But anything less and it probably doesn't. I like one global that you can use to potentially skip things on local workstations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean testing coverage of the code in tests/, not the code that is being tested. Surely all tests are running in CI?

else:
pytest.skip(msg)
return boto3.resource(
"s3",
aws_access_key_id=AWS_ACCESS_KEY_ID,
Expand All @@ -299,9 +313,13 @@ def s3_bucket_config(s3):


@pytest.fixture
def ios_bucket_config():
def ios_bucket_config(pytestconfig):
if not GCS_PRIVATE_KEY or not GCS_CLIENT_EMAIL:
pytest.skip("No GCS credentials")
msg = "No GCS credentials"
if pytestconfig.getoption("ci"):
pytest.fail(msg)
else:
pytest.skip(msg)
yield {
"id": "ios",
"type": "gcs",
Expand Down