Skip to content

Earthly #672

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

Merged
merged 18 commits into from
Nov 29, 2023
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
13 changes: 13 additions & 0 deletions .earthlyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
target
Dockerfile
dockerfile
.dockerignore
.env
.git
**/.temp
.gitignore
Earthfile
*/Earthfile
*/node_modules
node_modules
.earthlyignore
192 changes: 23 additions & 169 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,178 +2,32 @@ on: [push, workflow_dispatch]

name: "Build, test, clippy"
jobs:
fmt:
name: Rustfmt
earthly:
name: Earthly
runs-on: ubuntu-latest
env:
EARTHLY_TOKEN: ${{ secrets.EARTHLY_TOKEN }}
steps:
- run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- uses: actions-rs/cargo@v1
- uses: earthly/actions-setup@v1
with:
command: fmt
args: --all -- --check

build_js:
name: Build JS assets
runs-on: ubuntu-latest
steps:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: "latest"
- uses: actions/checkout@v2

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install JS deps
working-directory: ./browser/
run: |
pnpm install
pnpm run playwright-install

- name: Lint JS
working-directory: ./browser/
run: |
pnpm run lint

- name: Build JS
working-directory: ./browser/
run: |
pnpm run build

- name: Test JS (no e2e)
working-directory: ./browser/
run: |
pnpm run test

- name: Save JS Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: ./browser/data-browser/dist
e2e:
name: End-to-end tests
runs-on: ubuntu-latest
needs: [build_js]
steps:
- run: |
sudo apt-get update
sudo apt-get install -y webkit2gtk-4.0 libayatana-appindicator3-dev
- uses: actions/checkout@v3
- name: Download JS Build Artifact
uses: actions/download-artifact@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
name: build-artifact
path: ./browser/data-browser/dist

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy

- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
cache-all-crates: true

- uses: actions-rs/cargo@v1
name: cargo build
with:
command: build
args: --locked

- uses: actions-rs/cargo@v1
name: cargo clippy
with:
command: clippy
args: --no-deps

- uses: taiki-e/install-action@nextest
- uses: actions-rs/cargo@v1
name: cargo nextest run
with:
command: nextest
args: run --all-features --retries 3

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install Playwright
working-directory: ./browser/
username: joepmeneer
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Put back the git branch into git (Earthly uses it for tagging)
run: |
pnpm install
pnpm run playwright-install

- name: Run atomic-server in the background
run: nohup ./target/debug/atomic-server --initialize &

- name: Run end-to-end tests
working-directory: ./browser/
env:
FRONTEND_URL: http://localhost:9883
LANGUAGE: "en_GB"
DELETE_PREVIOUS_TEST_DRIVES: "false"
run: pnpm run test-e2e

# Coverage
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --locked --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true

- name: Upload test artifacts
uses: actions/upload-artifact@v3
if: failure()
with:
name: test-results
path: ./browser/data-browser/test-results/
branch=""
if [ -n "$GITHUB_HEAD_REF" ]; then
branch="$GITHUB_HEAD_REF"
else
branch="${GITHUB_REF##*/}"
fi
git checkout -b "$branch" || true
- name: Earthly build, test
run: earthly --org ontola --ci --sat henk -P +pipeline
- name: Earthly build and push docker
run: earthly --org ontola --ci --sat henk -P --push +docker --tag="latest,${{ github.sha }}"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ trace-*.json
**/.temp
.DS_Store
.cargo
artifact

# Local Netlify folder
.netlify
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"eslint.packageManager": "pnpm",
"eslint.quiet": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.eslint": "explicit"
},
"jest.enableInlineErrorMessages": true,
"jest.showCoverageOnLoad": true,
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ By far most changes relate to `atomic-server`, so if not specified, assume the c
**Changes to JS assets (including the front-end and JS libraries) are not shown here**, but in [`/browser/CHANGELOG`](/browser/CHANGELOG.md).
See [STATUS.md](server/STATUS.md) to learn more about which features will remain stable.

## UNRELEASED

- Use Earthly for CI: building, testing, pushing Docker images #576
- Host @tomic NPM docs [on Netlify](https://atomic-lib.netlify.app/) #707

## [v0.36.0] - 2023-11-02

- **Requires `--rebuild-index`**
Expand Down
Loading