-
Notifications
You must be signed in to change notification settings - Fork 31
133 lines (126 loc) · 4.15 KB
/
Copy pathci.yml
File metadata and controls
133 lines (126 loc) · 4.15 KB
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
name: CI
on:
push:
branches:
- main
pull_request:
permissions:
contents: write
jobs:
ci-data:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.fetch.outputs.result }}
steps:
- id: fetch
uses: oxidize-rb/actions/fetch-ci-data@v1
with:
stable-ruby-versions: |
# Explicitly include all Ruby versions we want to support
# to ensure binaries are built for each version
only: ['3.2', '3.3', '3.4', '4.0']
rspec:
runs-on: ${{ matrix.os }}
needs: ci-data
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
ruby: ${{ fromJSON(needs.ci-data.outputs.result).stable-ruby-versions }}
rust: ["stable"]
steps:
- uses: actions/checkout@v6
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: ${{ matrix.ruby }}
rustup-toolchain: ${{ matrix.rust }}
bundler-cache: true
cargo-cache: false
- name: Run ruby tests
run: bundle exec rake
- name: Compile rust ext
run: bundle exec rake compile:release
rspec_ruby_version_file:
name: "RSpec (ruby-version-file)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
rustup-toolchain: stable
bundler-cache: true
cargo-cache: false
- name: Run ruby tests
run: bundle exec rake
- name: Compile rust ext
run: bundle exec rake compile:release
static_type_check:
name: "Type Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run static type checks
run: bundle exec srb tc
notify_on_failure:
runs-on: ubuntu-latest
needs: [rspec, static_type_check]
if: ${{ failure() && github.ref == 'refs/heads/main' }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
steps:
- uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"text": "${{ github.repository }}/${{ github.ref }}: FAILED\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
check-release:
name: Check if release needed
runs-on: ubuntu-latest
needs: [rspec, rspec_ruby_version_file, static_type_check]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
should_release: ${{ steps.check.outputs.should_release }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v6
- id: check
run: |
VERSION=$(ruby -r ./lib/code_ownership/version.rb -e "puts CodeOwnership::VERSION")
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
"https://rubygems.org/api/v2/rubygems/code_ownership/versions/${VERSION}.json")
if [ "$STATUS" = "200" ]; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "::notice::code_ownership ${VERSION} already on RubyGems — skipping release."
else
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "::notice::code_ownership ${VERSION} not published — will release."
fi
release:
name: Release
needs: check-release
if: needs.check-release.outputs.should_release == 'true'
permissions:
contents: write
uses: ./.github/workflows/cd.yml
secrets: inherit
notify_on_release:
runs-on: ubuntu-latest
needs: [check-release, release]
if: ${{ github.ref == 'refs/heads/main' && needs.release.result == 'success' }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
steps:
- uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
"text": "🎉 Released ${{ github.repository }} v${{ needs.check-release.outputs.version }}"
}