forked from dependabot/dependabot-core
-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (102 loc) · 3.8 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: CI
on:
push:
branches:
- "actions/**"
- "wip/**"
- "main"
pull_request:
branches:
- "**"
permissions:
contents: read
jobs:
ci:
name: CI
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
- { path: bundler, name: bundler1 }
- { path: bundler, name: bundler2 }
- { path: cargo, name: cargo }
- { path: common, name: common }
- { path: composer, name: composer }
- { path: dep, name: dep }
- { path: docker, name: docker }
- { path: elm, name: elm }
- { path: git_submodules, name: git_submodules }
- { path: github_actions, name: github_actions }
- { path: go_modules, name: go_modules }
- { path: gradle, name: gradle }
- { path: hex, name: hex }
- { path: maven, name: maven }
- { path: npm_and_yarn, name: npm_and_yarn }
- { path: nuget, name: nuget }
- { path: omnibus, name: omnibus }
- { path: python, name: python }
- { path: terraform, name: terraform }
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare environment variables
run: |
echo "BRANCH_REF=$(echo '${{ github.ref }}' | sed -E 's/[^A-Za-z0-9]+/-/g')" >> $GITHUB_ENV
echo "BASE_IMAGE=ubuntu:18.04" >> $GITHUB_ENV
echo "CORE_IMAGE=dependabot/dependabot-core" >> $GITHUB_ENV
echo "CORE_CI_IMAGE=dependabot/dependabot-core-ci" >> $GITHUB_ENV
echo "CODE_DIR=/home/dependabot/dependabot-core" >> $GITHUB_ENV
- name: Log in to Docker registry
run: |
if [ -n "${{ secrets.DOCKER_USERNAME }}" ] && [ -n "${{ secrets.DOCKER_PASSWORD }}" ]; then
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
echo "DOCKER_LOGGED_IN=true" >> $GITHUB_ENV
else
echo "No Docker credentials, skipping login"
fi
- name: Build dependabot-core image
run: |
DOCKER_BUILDKIT=1 docker build \
-t "$CORE_IMAGE:latest" \
-t "$CORE_IMAGE:branch--$BRANCH_REF" \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from "$BASE_IMAGE" \
--cache-from "$CORE_IMAGE:branch--$BRANCH_REF" \
--cache-from "$CORE_IMAGE:latest" \
.
- name: Push dependabot-core image to Docker registry
if: env.DOCKER_LOGGED_IN == 'true'
run: |
docker push "$CORE_IMAGE:branch--$BRANCH_REF"
- name: Build dependabot-core-ci image
run: |
DOCKER_BUILDKIT=1 docker build \
-t "$CORE_CI_IMAGE:latest" \
-t "$CORE_CI_IMAGE:branch--$BRANCH_REF" \
-f Dockerfile.ci \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--cache-from "$CORE_CI_IMAGE:latest" \
--cache-from "$CORE_CI_IMAGE:branch--$BRANCH_REF" \
.
- name: Push dependabot-core-ci image to Docker registry
if: env.DOCKER_LOGGED_IN == 'true'
run: |
docker push "$CORE_CI_IMAGE:latest"
docker push "$CORE_CI_IMAGE:branch--$BRANCH_REF"
- name: Run ${{ matrix.suite.name }} tests
run: |
docker run \
--env "CI=true" \
--env "RAISE_ON_WARNINGS=true" \
--env "DEPENDABOT_TEST_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}" \
--env "SUITE_NAME=${{ matrix.suite.name }}" \
--rm "$CORE_CI_IMAGE" bash -c \
"cd /home/dependabot/dependabot-core/${{ matrix.suite.path }} && ./script/ci-test"
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt-get update -y && sudo apt-get install --no-install-recommends shellcheck
- run: ./bin/lint