Skip to content

Reorganize github workflows and use specific label [skip circleci] #2297

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 22 commits into from
Oct 28, 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
9 changes: 7 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defaults: &defaults
keys:
- v4-stack-cache-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "resolver.txt" }}

# Looking for the string [skip ci] in all the json returned by https://docs.github.com/en/rest/reference/pulls#get-a-pull-request
# Looking for the string [skip circleci] in all the json returned by https://docs.github.com/en/rest/reference/pulls#get-a-pull-request
- run:
name: Skip ci setup
command: |
Expand All @@ -26,7 +26,12 @@ defaults: &defaults
PULL_REQUEST_URL=${CIRCLE_PULL_REQUEST/github.com/api.github.com/repos}
PULL_REQUEST_URL=${PULL_REQUEST_URL/pull/pulls}
echo "PULL_REQUEST_URL: $PULL_REQUEST_URL"
SKIP_CI=$(curl $PULL_REQUEST_URL | grep -o "\\[skip ci\\]")
SKIP_CI=$(curl $PULL_REQUEST_URL | grep -o "\\[skip circleci\\]")
if [[ -z "$SKIP_CI" ]]; then
PULL_REQUEST_COMMENTS_URL=${PULL_REQUEST_URL/pulls/issues}/comments
echo "PULL_REQUEST_COMMENTS_URL: $PULL_REQUEST_COMMENTS_URL"
SKIP_CI=$(curl $PULL_REQUEST_COMMENTS_URL | grep -o "\\[skip circleci\\]")
fi
echo "SKIP_CI: $SKIP_CI"
fi
echo "export SKIP_CI=$SKIP_CI" >> $BASH_ENV
Expand Down
82 changes: 39 additions & 43 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
cancel_others: true
paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", ".circleci/**", "install/**", "**.nix", "**/test/**", "flake.lock", "**/README.md", "FUNDING.yml"]'

bench-init:
bench_init:
if: needs.pre_job.outputs.should_skip != 'true'
needs: pre_job
runs-on: ${{ matrix.os }}

Expand All @@ -28,19 +29,17 @@ jobs:
os: [ubuntu-latest]

steps:
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: actions/checkout@v2
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: git fetch origin master # check the master branch for benchmarking
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: haskell/actions/setup@v1
- uses: actions/checkout@v2

- run: git fetch origin master # check the master branch for benchmarking

- uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.2'
enable-stack: false

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Cache Cabal
- name: Cache Cabal
uses: actions/cache@v2
with:
path: |
Expand All @@ -52,55 +51,47 @@ jobs:
v2-${{ runner.os }}-${{ matrix.ghc }}-bench-
v2-${{ runner.os }}-${{ matrix.ghc }}

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: cabal update
- run: cabal update

# max-backjumps is increased as a temporary solution
# for dependency resolution failure
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
run: cabal configure --enable-benchmarks --max-backjumps 12000
- run: cabal configure --enable-benchmarks --max-backjumps 12000

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Build
- name: Build
shell: bash
run: cabal build ghcide:benchHist

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Bench init
- name: Bench init
shell: bash
run: cabal bench ghcide:benchHist -j --benchmark-options="all-binaries"

# tar is required to preserve file permissions
# compression speeds up upload/download nicely
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: tar workspace
- name: tar workspace
shell: bash
run: tar -czf workspace.tar.gz * .git

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: tar cabal
- name: tar cabal
run: |
cd ~/.cabal
tar -czf cabal.tar.gz *

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Upload workspace
- name: Upload workspace
uses: actions/upload-artifact@v2
with:
name: workspace
retention-days: 1
path: workspace.tar.gz

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Upload .cabal
- name: Upload .cabal
uses: actions/upload-artifact@v2
with:
name: cabal-home
retention-days: 1
path: ~/.cabal/cabal.tar.gz

bench-example:
needs: [bench-init, pre_job]
bench_example:
needs: [bench_init, pre_job]
runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -111,47 +102,40 @@ jobs:
example: ['cabal', 'lsp-types']

steps:
- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v1
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.2'
enable-stack: false

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Download cabal home
- name: Download cabal home
uses: actions/download-artifact@v2
with:
name: cabal-home
path: .

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Download workspace
- name: Download workspace
uses: actions/download-artifact@v2
with:
name: workspace
path: .

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: untar
- name: untar
run: |
mkdir -p ~/.cabal
tar xzf workspace.tar.gz
tar xzf cabal.tar.gz --directory ~/.cabal

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Bench
- name: Bench
shell: bash
run: cabal bench ghcide:benchHist -j --benchmark-options="${{ matrix.example }}"

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Display results
- name: Display results
shell: bash
run: |
column -s, -t < ghcide/bench-results/unprofiled/${{ matrix.example }}/results.csv | tee ghcide/bench-results/unprofiled/${{ matrix.example }}/results.txt

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Archive benchmarking artifacts
- name: Archive benchmarking artifacts
uses: actions/upload-artifact@v2
with:
name: bench-results-${{ runner.os }}-${{ matrix.ghc }}
Expand All @@ -161,12 +145,24 @@ jobs:
ghcide/bench-results/**/*.svg
ghcide/bench-results/**/*.eventlog.html

- if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
name: Archive benchmark logs
- name: Archive benchmark logs
uses: actions/upload-artifact@v2
with:
name: bench-logs-${{ runner.os }}-${{ matrix.ghc }}
path: |
ghcide/bench-results/**/*.log
ghcide/bench-results/**/*.eventlog
ghcide/bench-results/**/*.hp

post_job:
if: always()
runs-on: ubuntu-latest
needs: [pre_job, bench_init, bench_example]
steps:
- run: |
echo "jobs info: ${{ toJSON(needs) }}"
- if: contains(needs.*.result, 'failure')
run: exit 1
- if: contains(needs.*.result, 'cancelled')
name: cancelling
uses: andymckay/cancel-action@0.2
30 changes: 20 additions & 10 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:

# Enter the development shell and run `cabal build`
develop:
if: needs.pre_job.outputs.should_skip_develop != 'true'
needs: pre_job
runs-on: ${{ matrix.os }}

Expand All @@ -37,26 +38,22 @@ jobs:
os: [ubuntu-latest, macOS-latest]

steps:
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
submodules: true
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
uses: cachix/install-nix-action@v13
- uses: cachix/install-nix-action@v13
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/i6laym9jw3wg9mw6ncyrk6gjx4l34vvx/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
nix_path: nixpkgs=channel:nixos-unstable
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
uses: cachix/cachix-action@v10
- uses: cachix/cachix-action@v10
with:
name: haskell-language-server
# Disable pushing, we will do that in job `build`
skipPush: true
- if: ${{ needs.pre_job.outputs.should_skip_develop != 'true' }}
run: |
- run: |
nix develop --print-build-logs --command cabal update
nix develop --print-build-logs --command cabal build

Expand All @@ -66,10 +63,10 @@ jobs:
# 2. Nix files are changed (runs on PR)
build:
needs: pre_job
runs-on: ${{ matrix.os }}
runs-on: matrix.os
env:
HAS_TOKEN: ${{ secrets.HLS_CACHIX_AUTH_TOKEN != '' }}
if: ${{ needs.pre_job.outputs.should_skip_build != 'true' || (github.repository_owner == 'haskell' && github.ref == 'refs/heads/master') }}
if: (needs.pre_job.outputs.should_skip_build != 'true' && needs.pre_job.outputs.should_skip_pr != 'true') || (github.repository_owner == 'haskell' && github.ref == 'refs/heads/master')
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -104,3 +101,16 @@ jobs:
- name: Push binaries
if: ${{ env.HAS_TOKEN == 'true' }}
run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server

post_job:
if: always()
runs-on: ubuntu-latest
needs: [pre_job, develop, build]
steps:
- run: |
echo "jobs info: ${{ toJSON(needs) }}"
- if: contains(needs.*.result, 'failure')
run: exit 1
- if: contains(needs.*.result, 'cancelled')
name: cancelling
uses: andymckay/cancel-action@0.2
Loading