-
Notifications
You must be signed in to change notification settings - Fork 92
138 lines (117 loc) · 3.91 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: CI
on:
merge_group:
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
run: rustup update nightly && rustup default nightly && rustup component add rustfmt clippy
- name: Check the code formatting with rustfmt
run: cargo fmt --all -- --check
- name: Ensure there are no warnings with Clippy
run: cargo clippy --all -- -Dwarnings
- name: Check if the configuration is correct
run: |
cargo run -- create-lists
cargo run -- check-config
test:
name: Testing
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
channel: [nightly]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ matrix.channel }}
shell: bash
run: rustup update --no-self-update $CHANNEL && rustup default $CHANNEL
env:
CHANNEL: ${{ matrix.channel }}
- name: Build Crater
shell: bash
run: cargo build
- name: Run Crater tests
shell: bash
run: |
cargo run -- create-lists
cargo test
minicrater:
name: Minicrater
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
run: rustup update --no-self-update nightly && rustup default nightly
- name: Run minicrater
shell: bash
run: |
cargo run -- create-lists
cargo test -- --ignored --nocapture --test-threads 1
env:
MINICRATER_FAST_WORKSPACE_INIT: 1
MINICRATER_SHOW_OUTPUT: 1
docker-build:
name: Build the Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build -t crater .
- name: Prepare the Docker image to be uploaded
run: |
mkdir -p /tmp/docker-images
docker save crater | gzip > /tmp/docker-images/crater.tar.gz
- name: Upload the image to GitHub Actions artifacts
uses: actions/upload-artifact@v4
with:
name: docker-images
path: /tmp/docker-images
docker-upload:
name: Upload the Docker images to ECR
runs-on: ubuntu-latest
needs:
- lint
- test
- minicrater
- docker-build
steps:
- name: Download the image from GitHub Actions artifacts
uses: actions/download-artifact@v4
with:
name: docker-images
path: docker-images
- name: Load the downloaded image
run: cat docker-images/crater.tar.gz | gunzip | docker load
- name: Upload the Docker image to ECR
uses: rust-lang/simpleinfra/github-actions/upload-docker-image@master
with:
image: crater
repository: crater
region: us-west-1
aws_access_key_id: "${{ secrets.aws_access_key_id }}"
aws_secret_access_key: "${{ secrets.aws_secret_access_key }}"
conclusion:
needs: [docker-upload]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
# when the workflow is canceled manually.
#
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
steps:
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: Conclusion
run: |
# Print the dependent jobs to see them in the CI log
jq -C <<< '${{ toJson(needs) }}'
# Check if all jobs that we depend on (in the needs array) were successful.
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'