Skip to content

Commit af451dc

Browse files
Merge pull request #6 from BrosSquad/rewrite/v3-rust
Rewrite/v3 rust
2 parents 591b6a1 + 44030da commit af451dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2265
-1319
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hoster/tests/data/utf16-hosts-with-bom-bytes eol=crlf

.github/workflows/build.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'Build'
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
inputs:
7+
profile:
8+
description: 'Cargo build profile (debug|release|dist)'
9+
required: true
10+
type: string
11+
default: dist
12+
env:
13+
RUST_BACKTRACE: 1
14+
15+
jobs:
16+
build:
17+
strategy:
18+
matrix:
19+
rust:
20+
- stable
21+
os:
22+
- ubuntu-latest
23+
- windows-latest
24+
- macos-latest
25+
runs-on: ${{ matrix.os }}
26+
name: Build ${{ matrix.rust }} on ${{ matrix.os }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
- name: Install Rust (${{ matrix.rust }})
31+
uses: actions-rs/toolchain@v1
32+
with:
33+
profile: minimal
34+
toolchain: ${{ matrix.rust }}
35+
override: true
36+
- name: Test
37+
uses: actions-rs/cargo@v1
38+
id: build
39+
with:
40+
command: build
41+
args: --profile ${{ inputs.profile }} --all
42+
- name: Archive production artifacts
43+
if: ${{ matrix.os != 'windows-latest' }}
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: hosts-edit-binary-${{ matrix.os }}
47+
path: ./target/${{ inputs.profile }}/hosts-edit
48+
- name: Archive production artifacts
49+
if: ${{ matrix.os == 'windows-latest' }}
50+
uses: actions/upload-artifact@v3
51+
with:
52+
name: hosts-edit-binary-${{ matrix.os }}
53+
path: ./target/${{ inputs.profile }}/hosts-edit.exe

.github/workflows/release.yml

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
tags:
66
- 'v*'
77
jobs:
8-
release:
8+
create_release:
99
runs-on: ubuntu-latest
1010
outputs:
1111
upload_url: ${{ steps.create_release.outputs.upload_url }}
@@ -22,84 +22,43 @@ jobs:
2222
release_name: Release ${{ github.ref }}
2323
draft: false
2424
prerelease: false
25-
unix:
25+
build:
26+
uses: BrosSquad/hosts/.github/workflows/build.yml@master
27+
with:
28+
profile: dist
29+
release:
30+
needs: [create_release, build]
2631
strategy:
2732
matrix:
28-
os: [ubuntu-latest, macos-latest]
29-
go: [1.16.x]
30-
runs-on: ${{ matrix.os }}
31-
needs: release
33+
os:
34+
- ubuntu-latest
35+
- windows-latest
36+
- macos-latest
37+
runs-on: ubuntu-latest
3238
steps:
33-
- name: Checkout
34-
uses: actions/checkout@v2
35-
- uses: olegtarasov/[email protected]
36-
id: git_tag
39+
- name: Download 'Hosts-Edit' binary
40+
uses: actions/download-artifact@v3
3741
with:
38-
tagRegex: 'v(.*)'
39-
tagRegexGroup: 1
40-
- name: Install Go
41-
uses: actions/setup-go@v2
42-
with:
43-
go-version: ${{ matrix.go }}
44-
- uses: actions/cache@v2
45-
with:
46-
path: ~/go/pkg/mod
47-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
48-
restore-keys: |
49-
${{ runner.os }}-go-
50-
- name: Test
51-
run: make test RACE=1 ENVIRONMENT=production
52-
- name: Build
53-
run: make build VERSION=${{ steps.git_tag.outputs.tag }} RACE=0 ENVIRONMENT=production
54-
env:
55-
CGO_ENABLED: 0
42+
name: hosts-edit-binary-${{ matrix.os }}
5643
- name: Upload Release Asset
57-
id: upload-release-asset
44+
id: upload-release-asset-windows
45+
if: ${{ matrix.os == 'windows-latest' }}
5846
uses: actions/upload-release-asset@v1
5947
env:
6048
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6149
with:
62-
upload_url: ${{ needs.release.outputs.upload_url }}
63-
asset_path: ./bin/hosts
64-
asset_name: hosts-${{ matrix.os }}-${{ steps.git_tag.outputs.tag }}
50+
upload_url: ${{ needs.create_release.outputs.upload_url }}
51+
asset_path: ./hosts-edit.exe
52+
asset_name: hosts-edit-${{ matrix.os }}.exe
6553
asset_content_type: application/octet-stream
66-
windows:
67-
strategy:
68-
matrix:
69-
go: [1.16.x]
70-
runs-on: windows-latest
71-
needs: release
72-
steps:
73-
- name: Checkout
74-
uses: actions/checkout@v2
75-
- uses: olegtarasov/[email protected]
76-
id: git_tag
77-
with:
78-
tagRegex: 'v(.*)'
79-
tagRegexGroup: 1
80-
- name: Install Go
81-
uses: actions/setup-go@v2
82-
with:
83-
go-version: ${{ matrix.go }}
84-
- uses: actions/cache@v2
85-
with:
86-
path: ~/go/pkg/mod
87-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
88-
restore-keys: |
89-
${{ runner.os }}-go-
90-
- name: Test
91-
run: make test RACE=1 ENVIRONMENT=production
92-
- name: Build
93-
run: make build VERSION=${{ steps.git_tag.outputs.tag }} RACE=0 ENVIRONMENT=production EXT=.exe
94-
env:
95-
CGO_ENABLED: 0
9654
- name: Upload Release Asset
97-
id: upload-release-asset
55+
id: upload-release-asset-unix
56+
if: ${{ matrix.os != 'windows-latest' }}
9857
uses: actions/upload-release-asset@v1
9958
env:
10059
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10160
with:
102-
upload_url: ${{ needs.release.outputs.upload_url }}
103-
asset_path: ./bin/hosts.exe
104-
asset_name: hosts-windows-${{ steps.git_tag.outputs.tag }}.exe
61+
upload_url: ${{ needs.create_release.outputs.upload_url }}
62+
asset_path: ./hosts-edit
63+
asset_name: hosts-edit-${{ matrix.os }}
10564
asset_content_type: application/octet-stream

.github/workflows/test.yml

Lines changed: 72 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,83 @@ on:
88
branches:
99
- master
1010
- dev
11+
12+
env:
13+
RUST_BACKTRACE: 1
14+
1115
jobs:
12-
test:
16+
style:
1317
strategy:
1418
matrix:
15-
os: [ubuntu-latest, macos-latest, windows-latest]
16-
go: [1.15.x, 1.16.x]
19+
os: [ubuntu-latest]
1720
runs-on: ${{ matrix.os }}
1821
steps:
1922
- name: Checkout code
20-
uses: actions/checkout@v2
21-
- name: Install Go
22-
uses: actions/setup-go@v2
23+
uses: actions/checkout@v3
24+
- name: Install Rust
25+
uses: actions-rs/toolchain@v1
2326
with:
24-
go-version: 1.16.x
25-
- uses: actions/cache@v2
27+
profile: minimal
28+
toolchain: stable
29+
override: true
30+
components: rustfmt
31+
- name: cargo fmt --check
32+
uses: actions-rs/cargo@v1
33+
with:
34+
command: fmt
35+
args: --all -- --check
36+
test:
37+
strategy:
38+
matrix:
39+
rust:
40+
- stable
41+
os:
42+
- ubuntu-latest
43+
- windows-latest
44+
- macos-latest
45+
include:
46+
- rust: stable
47+
runs-on: ${{ matrix.os }}
48+
name: Test ${{ matrix.rust }} on ${{ matrix.os }}
49+
needs: [style]
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v3
53+
54+
- name: Install Rust (${{ matrix.rust }})
55+
uses: actions-rs/toolchain@v1
2656
with:
27-
path: ~/go/pkg/mod
28-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
29-
restore-keys: |
30-
${{ runner.os }}-go-
31-
- name: Test ${{ matrix.go }}
32-
run: make test RACE=1 ENVIRONMENT=development
57+
profile: minimal
58+
toolchain: ${{ matrix.rust }}
59+
override: true
60+
61+
- name: Test
62+
uses: actions-rs/cargo@v1
63+
with:
64+
command: test
65+
66+
- name: Test all benches
67+
if: matrix.benches
68+
uses: actions-rs/cargo@v1
69+
with:
70+
command: test
71+
args: --benches
72+
miri:
73+
name: Test with Miri
74+
needs: [style]
75+
runs-on: ubuntu-latest
76+
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v3
80+
81+
- name: Install Rust
82+
uses: actions-rs/toolchain@v1
83+
with:
84+
profile: minimal
85+
toolchain: nightly
86+
components: miri
87+
override: true
88+
89+
- name: Test
90+
run: MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1+
/target
12
.idea/
2-
.vscode/
3-
bin/
4-
coverage.txt

.vscode/launch.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": []
4+
}

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

.vscode/tasks.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "cargo",
6+
"command": "clippy",
7+
"problemMatcher": [
8+
"$rustc"
9+
],
10+
"group": "build",
11+
"label": "rust: cargo clippy"
12+
},
13+
{
14+
"type": "cargo",
15+
"command": "build",
16+
"problemMatcher": [
17+
"$rustc"
18+
],
19+
"args": [
20+
"--release"
21+
],
22+
"group": "build",
23+
"label": "rust: cargo build release"
24+
},
25+
{
26+
"type": "cargo",
27+
"command": "build",
28+
"problemMatcher": [
29+
"$rustc"
30+
],
31+
"group": "build",
32+
"label": "rust: cargo build"
33+
},
34+
{
35+
"type": "cargo",
36+
"command": "build",
37+
"problemMatcher": [
38+
"$rustc"
39+
],
40+
"args": [
41+
"--profile",
42+
"dist"
43+
],
44+
"group": "build",
45+
"label": "rust: cargo build dist"
46+
}
47+
]
48+
}

0 commit comments

Comments
 (0)